Skip to content

sosmongare/countries_api

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
env
 
 
 
 
 
 
 
 

Countries API

The Countries API is a Django-based RESTful API that provides information about different countries. It allows users to retrieve, create, update, and delete country data.

Introduction

The Countries API is built using Django, a powerful and flexible web framework for Python. It utilizes Django REST framework to expose the country data through a RESTful API.

Features

  • List all countries with their details
  • Retrieve information about a specific country by its ID
  • Create new countries
  • Update country details
  • Delete countries

Setup

  1. Clone the repository:
git clone https://github.com/sosmongare/countries_api.git
cd countries_api
  1. Create a virtual environment and activate it:
python3 -m venv env
# For Windows:
. env/Scripts/activate

# For macOS/Linux:
source . env/bin/activate
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Configure the database settings:

    • Open countries_api/settings.py and update the DATABASES settings to use your MySQL database credentials.
  2. Apply migrations:

python manage.py migrate
  1. Start the development server:
python manage.py runserver

The API will now be accessible at http://localhost:8000/countries/.

API Endpoints

The Countries API provides the following endpoints:

  • GET /countries/: Retrieve a list of all countries.
  • GET /countries/<id>/: Retrieve information about a specific country by its ID.
  • POST /countries/: Create a new country.
  • PUT /countries/<id>/: Update details of a specific country by its ID.
  • DELETE /countries/<id>/: Delete a specific country by its ID.

Usage

You can interact with the Countries API using tools like cURL, Postman, or any other HTTP client. For example:

  • To retrieve all countries:
curl -X GET http://localhost:8000/countries/
  • To create a new country:
curl -X POST -H "Content-Type: application/json" -d '{"name":"New Country", "capital":"Capital City", "population":1000000}' http://localhost:8000/countries/
  • To update a country:
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Updated Country", "capital":"Updated Capital City"}' http://localhost:8000/countries/<id>/
  • To delete a country:
curl -X DELETE http://localhost:8000/countries/<id>/

Contributing

Contributions are welcome! If you find any issues or want to add new features, feel free to open a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.


About

Countires Api using Django and Mysql Database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages