GithubHelp home page GithubHelp logo

abstractapi's Introduction

Django REST API Social Network

This project is a simple REST API based social network built using Django and Django REST Framework. It allows users to sign up, create text posts, view, like, and unlike other users' posts. The API also enriches the user with geolocation data based on the IP address used during signup and checks if the signup date coincides with a holiday in the user's country.

Installation

Clone the repository:

git clone https://github.com/siddythings/abstractapi.git

Change into the project directory:

cd abstractapi

Install the dependencies:

pip install -r requirements.txt

Set up the database:

python manage.py migrate

Create a superuser (admin) account:

python manage.py createsuperuser

Configuration

Obtain API keys:

  • Abstract API: Register for an account and obtain an API key from Abstract API.

Update the settings:

  • Open social_network/settings.py and replace GEOLOCATION_ABSTRACT_API_KEY and HOLIDAY_ABSTRACT_API_KEY with your Abstract API key.

Usage

Start the development server:

python manage.py runserver
  1. Access the API endpoints:
  • Open your browser or API testing tool and navigate to http://localhost:8000/api/.
  1. API Endpoints:
- User Signup:
- 
  - Route: POST `/api/register/`
  - Request body: {
    "username":"admin2",
    "password": "12345678@#",
    "password2": "12345678@#",
    "email":"[email protected]"
}
- User Login:
  - Route: POST `/api/login/`
  - Request body: {
    "password": "12345678@#",
    "email":"[email protected]"
}
  - Response: JWT token
- Get User Data:
  - Route: GET `/api/users/{user_id}/`
  - Authorization header: Bearer {JWT-token}
- Create Post:
  - Route: POST `/api/posts/`
  - Request body: { "content": "This is my post." }
  - Authorization header: Bearer {JWT-token}
- Read Post:
  - Route: GET `/api/posts/{post_id}/`
  - Request body: {"content":"Hello"}
- Update Post:
  - Route: PUT `/api/posts/{post_id}/`
  - Request body: { "content": "Updated post content." }
  - Authorization header: Bearer {JWT-token}
- Delete Post:
  - Route: DELETE `/api/posts/{post_id}/`
  - Authorization header: Bearer {JWT-token}
- Like Post:
  - Route: POST `/api/posts/{post_id}/like/`
  - Authorization header: Bearer {JWT-token}
- Unlike Post:
  - Route: POST `/api/posts/{post_id}/unlike/`
  - Authorization header: Bearer {JWT-token}

** API Test

python manage.py test

abstractapi's People

Watchers

siddhart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.