Skip to main content

Sync any REST API to PostgreSQL with schema inference

Project description

RestBase

Python License: MIT GitHub Repo

RestBase is a Python-based CLI tool that lets you fetch data from any REST API and sync it directly into a PostgreSQL database. It automatically infers table schemas from JSON responses, creates tables, and inserts data — no SQL or ORM required.


🚀 Features

  • 🌐 Query parameter support per endpoint
  • 🔍 Automatic schema inference from JSON
  • 📦 Nested JSON handled as JSONB columns
  • 🛠 Table creation only if not already present
  • ⚡ Fast, minimal CLI
  • ✅ Interactive config builder (no manual editing)

📦 Installation

Install directly from PyPI:

pip install restbase-cli

restbase

Or via Python module

python -m restbase

🛠 First-Time Setup

When you first run restbase, it will ask you for:

  • API base URL and endpoints
  • Optional query parameters
  • PostgreSQL credentials

This generates a config.yaml file used for syncing.


🧪 Example config.yaml

api:
  base_url: https://api.openbrewerydb.org/v1
  headers: {}
  endpoints:
    - path: /breweries
      params:
        by_city: san_diego
postgres:
  host: localhost
  port: 5432
  dbname: restbase_db
  user: postgres
  password: secret

🔧 Tech Stack

  • Python 3.7+
  • PostgreSQL
  • Libraries: requests, psycopg2-binary, PyYAML

🙋 Contributing

Pull requests are welcome!

To run the project locally:

git clone https://github.com/soumyadeep423/restbase-cli.git
cd restbase-cli
pip install .
pip install -e . #edit mode
restbase

📝 License

Licensed under the MIT License.


📫 Author

Soumyadeep Das GitHub: @soumyadeep423


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

restbase_cli-0.0.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

restbase_cli-0.0.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file restbase_cli-0.0.2.tar.gz.

File metadata

  • Download URL: restbase_cli-0.0.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for restbase_cli-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0c12c1461362e4a8de50787277687de679da344bc86a4b754ea4f8c8c44a9ba8
MD5 f5b8a64ec882a58bb96b91e352f6d7b1
BLAKE2b-256 97bf489e56687718cfea299bd31ee36380fb58d5e1eb76ae49343055460736c0

See more details on using hashes here.

File details

Details for the file restbase_cli-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: restbase_cli-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for restbase_cli-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ccfbea71e3fb485ddb22a54ef2495992d473017097364bc04dbcdcff9aa02497
MD5 d3d5c02eb5c130be75454fd5f4d757b6
BLAKE2b-256 4cfdc56d248b979ce0c143e1850e695da8ece7f54a6659a15684a92000cbaf2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page