A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

Instagram-BackendAPI

A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

External Dependencies

  • mongo-driver
  • godotenv (to handle secrets using environment variables, not required)

Directory Structure

├── go.mod
├── go.sum
├── helper
│   └── connect.go
├── main.go
├── main_test.go
└── models
    └── models.go
  • go.mod, go.sum Manages dependencies
  • connect.go Establishes a connection to the MongoDB clusters
  • models.go Defines the model objects
  • main.go Primary file to handle http requests
  • main_test.go Unit testing script

Endpoints

/api/posts

creates a post using data from the POST request's body

/api/posts/

fetches post details for the given id

/api/posts/users/ ?limit={}&lastid={}

fetches posts of the user with given id within a limit and with ids greater than lastid (if lastid is not null)

/api/users

creates a user and encrypts the password using ciphers before storing

/api/users/

fetches user details of given id

Pagination

The API employs an id-based pagination for the /api/posts/users/ endpoint. On the initial call, the limit parameter must be passed along with the request. The API returns the requsted number of posts and the id of the last post. Subsequent calls from the front-end must also contain a lastid parameter with the id that was returned on the previous call. This ensures that the second call returns posts starting with ids greater than the lastid , and that the API response doesn't explode in size.

Testing

Usage

  1. clone the repo git clone https://github.com/VoidlessVoid7/Instagram-BackendAPI .
  2. go build main.go
  3. go run ./

Screenshots

  • Creating a post

  • Fetching a post

  • Create a user

  • Fetch a user

  • Fetch posts created by a user

Similar Resources

Demo application to implement a REST api backend service for an android app using the Go aah framework.

aah-recycleview-backend This tutorial is based on the aah framework to implement a REST API form of CRUD application services, taking "IN-MEMORY" stor

Jan 28, 2022

Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Nov 21, 2021

Backend to project Dating App. Written in GO, utilising Gin. MongoDB, AWS S3 and SNS.

Dating API Backend to project Dating App. Written in GO, utilising Gin. MongoDB, AWS S3 and SNS. In order to run simply type "go run ." The API requir

Apr 12, 2022

This web app made with Go, and database handled with GraphQL lets me decide what to watch next! I can wishlist or mark a movie watched to manage my movie watchlist. Users worldwide can suggest me anything to watch and add it to my watchlist.

This web app made with Go, and database handled with GraphQL lets me decide what to watch next! I can wishlist or mark a movie watched to manage my movie watchlist. Users worldwide can suggest me anything to watch and add it to my watchlist.

Next-watch website - Next watch Introduction This web app made with Go, and database handled with GraphQL lets me decide what to watch next! I can wis

Oct 1, 2021

Simple control panel for Golang based on Gin framework and MongoDB

Simple control panel for Golang based on Gin framework and MongoDB

Summer panel Simple control panel for Golang based on Gin framework and MongoDB How To Install go install github.com/night-codes/summer/summerGen@late

Dec 16, 2022

A fully functional Ecommerce API in GO GIN Framework and mongoDB with JWT Authentication

A fully functional Ecommerce API in GO GIN Framework and mongoDB  with JWT Authentication

Fully functional ECOMMERCE API USING GIN FRAMEWORK AND MONGODB -----Initial Release v2.30 ⚠️ Not tested the efficiency project structure Ecommerce 📁

Dec 11, 2022

Chat backend which serves REST APIs

Chat backend which serves REST APIs

Nov 24, 2021

Users API Service

Users API Service

bookstore_users-api Users API Service Overview This application handles users. Project Structure This project was written in golang, designed to use M

Feb 12, 2022

REST API for a shoe store using Go and Gin Web Framework

REST API for a shoe store using Go and Gin Web Framework This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go

Dec 26, 2021
Instagram Backend HTTP REST API using GO Lang and Mongo DB

Instagram Backend HTTP REST API using GO Lang and Mongo DB Project for Appointy Summer Internship . Project built within 25 hrs, with no prior knowled

Oct 10, 2021
It is a clone of the CRUD operations on Instagram which can create, get, create posts and get the post along with pagination
It is a clone of the CRUD operations on Instagram which can create, get, create posts and get the post along with pagination

Instagram-API-Clone It is a basic version of a RESTful API based on Instagram where we can create user, get the users, create post and get post and ge

Jan 25, 2022
REST API of Instagram's functionalities; developed using GO (and Mongo).
REST API of Instagram's functionalities; developed using GO (and Mongo).

Instagram-backend-api REST API of Instagram's functionalities; developed using GO (and Mongo). Constraints: Complete API has been developed using Go M

Oct 9, 2021
Simple vanilla Go CRUD application with mongoDB database with its mflix dataset that I use for my thesis about benchmarking REST API and GraphQL.

Go GraphQL Simple vanilla Go CRUD application with mongoDB database with its mflix dataset that I use for my thesis about benchmarking REST API and Gr

Oct 15, 2021
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Jul 19, 2022
Simple Bank is a simple REST API that allows users to perform transferences with each other.

Simple Bank is a simple REST API that allows users to perform transferences with each other. ?? Technologies Golang Docker PostgreSQ

Feb 15, 2022
GinGoExample - Implement rest api using gin and go and mongodb

GinGoExample Implement rest api using gin and go and mongodb Optimizations using Singlton pattern to avoid repetetive commiunication with mongodb . Fe

Mar 25, 2022
Echo-mongo-api - Simple Golang REST application with Echo Framework & MongoDB

Echo-mongo-api - Simple Golang REST application with Echo Framework & MongoDB

Feb 14, 2022
Simple Go BE to serve blog posts

Simple Go BE to serve blog posts

Jan 25, 2022
The source code for workshop Scalable architecture using Redis as backend database using Golang + Redis

The source code for workshop Scalable architecture using Redis as backend database using Golang + Redis

Sep 23, 2022