Skip to main content

An API Client for the Neon API.

Project description

neon_api: an api wrapper for the Neon API.

neon_api is a Python wrapper designed to simplify interactions with the Neon API. It provides a convenient way for developers to integrate their Python applications with the Neon platform, offering methods to manage API keys, projects, branches, databases, endpoints, roles, and operations programmatically.

With neon_api, you can automate tasks, streamline workflows, and build powerful integrations with ease.

Installation

$ pip install neon-api

Usage

Documentation is available on ReadTheDocs.

from neon_api import NeonAPI

# Initialize the client.
neon = NeonAPI(api_key='your_api_key')

Remember that you should never expose your api_key and handle it carefully since it gives access to sensitive data. It's better to set it as an environment variable (e.g. NEON_API_KEY + accompanying neon_client.from_environ()).


Methods of the NeonAPI class:

  • me(): Returns the current user.

Manage API keys:

  • api_keys(): Returns a list of API keys.
  • api_key_create(**json): Creates an API key.
  • api_key_delete(key_id): Deletes a given API key.

Manage projects:

  • projects(): Returns a list of projects.
  • project(project_id): Returns a specific project.
  • project_create(project_id, **json): Creates a new project.
  • project_update(project_id, **json): Updates a given project.
  • project_delete(project_id): Deletes a given project.
  • project_permissions(project_id): Returns a list of permissions for a given project.
  • project_permissions_grant(project_id, **json): Grant permissions to a given project.
  • project_permissions_revoke(project_id, **json): Revoke permissions from a given project.

Manage branches:

  • branches(project_id): Returns a list of branches for a given project.
  • branch(project_id, branch_id): Returns a specific branch.
  • branch_create(project_id, **json): Creates a new branch.
  • branch_update(project_id, branch_id, **json): Updates a given branch.
  • branch_delete(project_id, branch_id): Deletes a given branch.
  • branch_set_as_primary(project_id, branch_id): Sets a given branch as primary.

Manage databases:

  • databases(project_id, branch_id): Returns a list of databases for a given project and branch.
  • database(project_id, branch_id, database_id): Returns a specific database.
  • database_create(project_id, branch_id, **json): Creates a new database.
  • database_update(project_id, branch_id, **json): Updates a given database.
  • database_delete(project_id, branch_id, database_id): Deletes a given database.

Manage endpoints:

  • endpoints(project_id, branch_id): Returns a list of endpoints for a given project and branch.
  • endpoint_create(project_id, branch_id, **json): Creates a new endpoint.
  • endpoint_update(project_id, branch_id, endpoint_id, **json): Updates a given endpoint.
  • endpoint_delete(project_id, branch_id, endpoint_id): Deletes a given endpoint.
  • endpoint_start(project_id, branch_id, endpoint_id): Starts a given endpoint.
  • endpoint_suspend(project_id, branch_id, endpoint_id): Suspends a given endpoint.

Manage roles:

  • roles(project_id, branch_id): Returns a list of roles for a given project and branch.
  • role(project_id, branch_id, role_name): Returns a specific role.
  • role_create(project_id, branch_id, role_name): Creates a new role.
  • role_delete(project_id, branch_id, role_name): Deletes a given role.
  • role_password_reveal(project_id, branch_id, role_name): Reveals the password for a given role.
  • role_password_reset(project_id, branch_id, role_name): Resets the password for a given role.

Manage operations:

  • operations(project_id): Returns a list of operations for a given project.
  • operation(project_id, operation_id): Returns a specific operation.

Experimental:

  • consumption(): Returns a list of project consumption metrics.

View the Neon API documentation for more information on the available endpoints and their parameters.

Development

Installation is simple with pipenv. Just run the following command in the root directory of the repository:

$ pipenv install --dev

This will install all the necessary dependencies for development.

To run the tests, use the following command:

$ make test

The tests don't require an internet connection, as they are mocked using the pytest-vcr library. To record new cassettes, use the following command:

$ make record

This will record new cassettes for the tests. Make sure to commit these cassettes along with your changes.

License & Copyright

MIT licensed.

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

neon-api-0.1.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

neon_api-0.1.0-py2.py3-none-any.whl (15.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file neon-api-0.1.0.tar.gz.

File metadata

  • Download URL: neon-api-0.1.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for neon-api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6370966682b088d9bddbf2ba248a46a09d394f450eea05cc85a2fbc5a553feaf
MD5 89626290c13c4e8aeded7b94955626c5
BLAKE2b-256 c19d64e2511f925f610f2a7477f1f682e484ebf04ce9cbadd1c4b58992e24d6c

See more details on using hashes here.

File details

Details for the file neon_api-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: neon_api-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for neon_api-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4ff64fdbb39de644deb2973a63e0427132aceff565f4e910748d237554305820
MD5 ad2369290b23c6b15717a6fe255ae1c4
BLAKE2b-256 6d97bfdbb56fc1f5a81b3b9dd1081e61dbf2a84d7bdfd296ada1b308c3d7b28e

See more details on using hashes here.

Supported by

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