Skip to content

grealyve/Stockapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StocksAPI Documentation

Welcome to the documentation for the StocksAPI, a simple RESTful API for managing stock information. This API is built using the Go programming language and the Gorilla Mux router.

Table of Contents

Endpoints

Get Stock

Get information about a specific stock by providing its ID.

  • Endpoint: /api/stock/{id}
  • Method: GET
  • Response:
    {
      "name": "Apple Inc."
      "price": 150,
      "company":"Apple"
    }

Get All Stocks

Get a list of all available stocks.

  • Endpoint: /api/stock
  • Method: GET
  • Response:
    {
      "stockid":1,
      "name": "Apple Inc.",
      "price": 150,
      "company":"Apple"
    },
    // Other stock objects

getall

Create Stock

Create a new stock entry.

  • Endpoint: /api/newstock
  • Method: POST
  • Response:
    {
      "id": 1,
      "message": "stock created successfully",
    }
  • Sample Request: newstock

Update Stock

Update information about a specific stock by providing its ID.

  • Endpoint: /api/stock/{id}
  • Method: PUT
  • Response:
    {
      "id": 1,
      "message": "stock created successfully",
    }
  • Sample Request: update

Delete Stock

Delete a stock entry by providing its ID.

  • Endpoint: /api/delete/{id}
  • Method: DELETE
  • Sample request and response: delete

Setup

To run the StocksAPI on your local machine, follow these steps:

  1. Clone this repository.
  2. Make sure you have Go (Golang) installed on your system.
  3. Run the following command to start the server:
go run main.go
  1. The API will be accessible at http://localhost:8000
  2. To be able to create the necessary SQL table, you need to execute these commands in the postgresql docker:
psql -U grealyve -d stockapi
CREATE DATABASE stockapi;
CREATE TABLE stocks(stockid SERIAL PRIMARY KEY, name TEXT, price INT, company TEXT);

Usage

Feel free to use and modify this API for your own projects. You can integrate it with databases, add authentication, and more. If you encounter any issues or have suggestions, please open an issue on this repository.

Referrence:

https://youtu.be/1nLH4J-DRLg?list=PL5dTjWUk_cPYztKD7WxVFluHvpBNM28N9

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages