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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: restbase_cli-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 440b99a96fe9f294e99c9e7be23777cef3bdc19082b8b2e2503100ab4f1a789b
MD5 963bd56d0d6f29e6191aab771a6d9557
BLAKE2b-256 8088a0ba4a7366d8350293274f9dd8a3e559ba8a0ca8c0d449c1544ec6a65e38

See more details on using hashes here.

File details

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

File metadata

  • Download URL: restbase_cli-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b06cc3e35d7accbac426cd4fed36c62d3e92d269ca5a61eaa3ebb4398e27ed31
MD5 1027dc1536a264ae62b1a14846e0868b
BLAKE2b-256 6571ef55c47854efad2312d9d1474fa217d2af681934408f0ccb60a520e440ea

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