REST API made using native Golang libraries. This API resembles the basic working of Instagram.

Overview

Logo

Golang RESTful API for Instagram

A Go based REST API built using native libraries. The API has been thoroughly worked through with Postman.

Routes include

  • User Route: These route includes the functionality of fetchUser and addUser.
  • Auth Route: Authentication for user is done using jwt.
  • FileHandler Route: Worked with GridFS to store files as fs.chunks . Added functionality to uploadFile and downloadFile.
  • Post Route: Functionality to create a post having functionality to uploadFile, desctiption, title.

MongoDB MongoDB is serving as the required database for all the storage functionality of this api. To access the MongoDB locally we used a docker container to run an instance of it binding the same to localhost port 27017 using -p 27017:27017.

docker run --name MongoREST -p 27017:27017 -d mongo:latest

Run Locally

Clone the project and navigate to the cloned repo.

  git clone https://github.com/bhavyagoel/GoRestAPI.git
  cd GoRestAPI

Install go dependencies by initialising a local env

go mod init
go mod tidy

Run the API Server

go run main.go

API Reference

Get details by UserID

  GET /user/getUserById
Parameter Type Description
id string Required UserID to fetch details

Dummy Response

{
    "Email": "[email protected]",
    "Password": "$2a$14$vJSwx9sOr2e9KMLiVji9tOfB5AbMjro69R/D1wN5Yqa/IpFMCr2Tq",
    "_id": "61617e08b11882299ca8a3fa",
    "id": "393d0be9-1091-4bd0-822b-915980d94b6d",
    "name": "Jane Dow",
    "post": [
        "56f18233-07bc-4472-9f71-4192f3cc2a3f.jpg",
        "927d4eef-7a77-4865-9cb3-0907fa44a871.jpg"
    ]
}

Add User To Database

  POST /user/addUser
Parameter Type Description
Name string Your Name as query Parameter
Email string Your Email as query Parameter
Password string Your Password as query Parameter. Hashed of the same will be saved in db

Note: The string password from the POST request will be automatically hashed using golang.org/x/crypto/bcrypt.
Dummy Response

{
    "message": "User added successfully",
    "result": {
        "InsertedID": "6161e51740c7852d0e45a540"
    }
}

Adding a POST by UserId

To add A post Under a user with a given Id following are the query parma

Parameter Type Description
Id string UUID Generated By github.com/google/uuid package
Title string Title to Your Post passed as a String
Description string A paragraph long Description of the post
urlToImage string URI to the local image location
publishedAt string TimeStamp Generated using time.now()
fileName string Unique fileName Generated github.com/google/uuid
userId string userId that links the post and the user
{
    "fileName": "3b59e4c8-9c75-4e4d-a716-4d18f1e5d22e.jpg",
    "fileSize": 171959,
    "id": "6161eb3a2318903450b28e0e",
    "message": "Successfully uploaded",
    "post": {},
    "user": {
        "Email": "\"[email protected]\"",
        "Password": "$2a$14$r/yybaVD9/JgjSY8sP5.XezjyBLzHrARar175YBuneKAYvn5r26hO",
        "_id": "6161eb1c2318903450b28e0a",
        "id": "d3e1fd98-0348-429f-9963-de9433960276",
        "name": "\"Jane Doe\"\n"
    }
}

Testing

To run tests, run the following command The unit tests can be found nested inside the test directory

    cd test/
    go test -v 

TODO

  • Containerising the API using docker
  • Deploying the API to Postman

Badges

MIT License

Creator

Screenshots

Screenshots for the same can be found under the img sub-folder.

You might also like...
Simple REST-API implementation using Golang with several packages (Echo, GORM) and Docker

Simple REST-API Boilerplate This is a simple implementation of REST-API using Golang and several packages (Echo and GORM). By default, I use PostgreSQ

Go WhatsApp REST API Implementation Using Fiber And Swagger
Go WhatsApp REST API Implementation Using Fiber And Swagger

Go WhatsApp REST API Implementation Using Fiber And Swagger Package cooljar/go-whatsapp-fiber Implements the WhatsApp Web API using Fiber web framewor

A REST web-service sample project written in Golang using go-fiber, GORM and PostgreSQL

backend A REST web-service sample project written in Golang using go-fiber, GORM and PostgreSQL How to run Make sure you have Go installed (download).

An example implementation of a REST interface in Golang using primarily the standard library.

REST API in Golang This is an example REST API implementation using primarily the standard library. The exceptions are as follows. github.com/gorilla/

A multiformat-inspired go module for working with multiple kinds of keypairs.

go-multikeypair A multiformats-inspired module for encoding cryptographic keypairs. Install At a shell within your go module: go get github.com/proofz

package for building REST-style Web Services using Go

go-restful package for building REST-style Web Services using Google Go Code examples using v3 REST asks developers to use HTTP methods explicitly and

Building basic API with go, gin and gorm

Project Description Terima kasih sudah berkunjung ke halaman repositori ini, repositori ini berisi basic RESTFUL API dengan menggunakan teknologi seba

🍐 Elegant Golang REST API Framework
🍐 Elegant Golang REST API Framework

An Elegant Golang Web Framework Goyave is a progressive and accessible web application framework focused on REST APIs, aimed at making backend develop

API REST with Golang. Not directly mine.

REST API: API REST with HTTP Methods like: GET & GET ONE PUT POST DELETE To build a compiled server: CompiledDaemon To develop on a compiled server:

Owner
Bhavya Goel
Research Intern at Samsung R&D
Bhavya Goel
A rest api with the crud methods made it in golang

go-API-REST A rest api made it in golang that connects to a mongodb database This API is compatible with the Angular frontend from https://github.com/

Sergio 5 Apr 26, 2022
Rest-and-go-master - A basic online store API written to learn Go Programming Language

rest-and-go(Not maintained actively) A basic online store API written to learn G

urobin84 0 Jan 12, 2022
REST Layer, Go (golang) REST API framework

REST Layer REST APIs made easy. REST Layer is an API framework heavily inspired by the excellent Python Eve. It helps you create a comprehensive, cust

Olivier Poitrey 1.2k Sep 20, 2022
Httpserver go - Server using only the go's libraries

API Rest Server This server use only the standard library of go (http, fmt and j

Andres Alvarez 0 Jun 21, 2022
REST api using fiber framework written in golang and using firebase ecosystem to authentication, storage and firestore as a db and use clean architecture as base

Backend API Example FiberGo Framework Docs : https://github.com/gofiber Info This application using firebase ecosystem Firebase Auth Cloud Storage Fir

Atilla Pehlivan 3 May 31, 2022
A very basic REST service for JSON data - enough for prototyping and MVPs!

caffeine - minimum viable backend A very basic REST service for JSON data - enough for prototyping and MVPs! Features: no need to set up a database, a

aw4y 1.2k Sep 16, 2022
💫 API made in Go using MongoDB and JWT.

?? Go MongoDB API ?? What is that API made in Go using MongoDB and JWT. ?? Features Not many libs & clean code JWT & MongoDB 3 routes (GET /token, GET

Rémy Martin 9 Sep 24, 2022
QOR is a set of libraries written in Go that abstracts common features needed for business applications, CMSs, and E-commerce systems.

QOR English Chat Room: 中文聊天室: For security issues, please send us an email to [email protected] and give us time to respond BEFORE posting as an iss

QOR 5.1k Sep 24, 2022
A Simple REST API Build Using Golang

gorestapi A Simple REST API Build Using Golang About gorestapi: a simple music restapi that retrives info about the author, album name, price of it ge

Krisna Pranav 13 Nov 21, 2021
Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Example Golang API backend rest implementation mini project Point Of Sale using Gin Framework and Gorm ORM Database.

Restu Wahyu Saputra 25 Aug 23, 2022