Skip to content

cavp28/JSON-dummy-data-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Dummy Data API

JSON Dummy Data API is a FastAPI application that generates JSON data based on a provided format using any model from Github's Marketplace. The application exposes an endpoint to generate a list of JSON objects with dummy data.

Getting Started

Prerequisites

  • Python 3.9+
  • Docker (optional, for containerized deployment)
  • Github Personal Token as enviroment variable named:
    • GITHUB_TOKEN

Installation

  1. Clone the repository:

    git clone https://github.com/cavp28/JSON-dummy-data-API.git
    cd JSON-dummy-data-API
  2. Create and active a virutal enviroment:

    python -m venv env
    source env/bin/activate  # On Windows use `env\Scripts\activate`
  3. Install the required dependencies:

    pip install -r requirements.txt
  4. Set up your environment variables:

    export GITHUB_TOKEN=your_github_token

Usage

Running the application

  1. Start the FastAPI served:
fastapi dev main.py
  1. Access the API Documentation at http://127.0.0.1:8000/docs

Running with Docker

  1. Build the Docker image:
docker-compose build
  1. Run the Docker container with docker compose:
docker-compose up

Here are some examples of how to use the TellMeSomething project:

Endpoint

POST /generate_json

Generates a list of JSON objects with dummy data based on the provided format.

Request:
  • max_rows (optional, default: 10): The number of JSON objects to generate.
  • details (optional, default: ""): Additional details or instruct
  • A JSON object specifying the format of the data.
    • {"key_name": "data_type"}
Use Cases
  1. Testing APIs: Generate dummy data to test your APIs without manually creating JSON objects.
  2. Prototyping: Quickly generate sample data for prototyping and development.
  3. Data Validation: Ensure that your application can handle various data formats and structures.
Example
Request
POST /generate_json
Content-Type: application/json

{
    "name": "string",
    "age": "integer",
    "email": "string"
}
Response
[
    {
        "name": "John Doe",
        "age": 30,
        "email": "john.doe@example.com"
    },
    {
        "name": "Jane Smith",
        "age": 25,
        "email": "jane.smith@example.com"
    },
    ...
]
Generate 5 user profiles
Request
# POST /generate_json?max_rows=5
# Content-Type: application/json

{
    "username": "string",
    "password": "string",
    "email": "string"
}
Response
[
    {
        "username": "user1",
        "password": "pass1",
        "email": "user1@example.com"
    },
    {
        "username": "user2",
        "password": "pass2",
        "email": "user2@example.com"
    },
    ...
]
Generate 3 product entries with details
Request
POST '/generate_json?max_rows=3&details=Include+product+descriptions' \
--header 'Content-Type: application/json' \
--data '{
    "product_name": "string",
    "price": "float",
    "description": "string"
}'
Response
[
    {
        "product_name": "Product A",
        "price": 19.99,
        "description": "A high-quality product."
    },
    {
        "product_name": "Product B",
        "price": 29.99,
        "description": "An excellent choice for your needs."
    },
    ...
]
Generate 5 users with names from Latin America
Request
POST '/generate_json?max_rows=5&details=names%20must%20be%20from%20latin%20america' \
--header 'Content-Type: application/json' \
--data '{
    "full_name": "string",
    "country": "string",
    "birth_date": "date",
    "is_alive": "boolean",
    "money": "int",
    "interest_rate": "float"
}'
Response
[
    {
        "full_name": "José Luis Pérez",
        "country": "Mexico",
        "birth_date": "1985-06-15",
        "is_alive": true,
        "money": 25000,
        "interest_rate": 3.5
    },
    {
        "full_name": "María Fernanda Gómez",
        "country": "Colombia",
        "birth_date": "1990-03-22",
        "is_alive": true,
        "money": 15000,
        "interest_rate": 4.0
    },
    {
        "full_name": "Carlos Alberto Sánchez",
        "country": "Argentina",
        "birth_date": "1978-11-05",
        "is_alive": false,
        "money": 5000,
        "interest_rate": 2.1
    },
    {
        "full_name": "Lucía Martínez",
        "country": "Chile",
        "birth_date": "1992-08-10",
        "is_alive": true,
        "money": 30000,
        "interest_rate": 3.8
    },
    {
        "full_name": "Andrés Felipe Torres",
        "country": "Peru",
        "birth_date": "1980-04-30",
        "is_alive": false,
        "money": 7000,
        "interest_rate": 2.5
    }
]

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

About

FastAPI connected with ChatGPT using Github Token

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors