{"id":20008091,"url":"https://github.com/kennethreitz/neon-api-python","last_synced_at":"2025-08-27T15:09:20.609Z","repository":{"id":224736425,"uuid":"745133423","full_name":"neondatabase/neon-api-python","owner":"neondatabase","description":"a Python client for the Neon API","archived":false,"fork":false,"pushed_at":"2024-08-10T00:32:17.000Z","size":397,"stargazers_count":13,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-06T09:12:21.412Z","etag":null,"topics":["api","client","http","neon","pg","postgres","python","rest"],"latest_commit_sha":null,"homepage":"https://neon-api-python.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neondatabase.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-18T17:52:35.000Z","updated_at":"2024-11-01T14:14:54.000Z","dependencies_parsed_at":"2024-03-25T20:37:53.031Z","dependency_job_id":"52446f68-b227-406a-995b-eedb8af17051","html_url":"https://github.com/neondatabase/neon-api-python","commit_stats":null,"previous_names":["kennethreitz/neon-client","kennethreitz/neon-api-python","kennethreitz/neon-client-python","neondatabase/neon-api-python"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neondatabase%2Fneon-api-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neondatabase%2Fneon-api-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neondatabase%2Fneon-api-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neondatabase%2Fneon-api-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neondatabase","download_url":"https://codeload.github.com/neondatabase/neon-api-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224406200,"owners_count":17305725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","http","neon","pg","postgres","python","rest"],"created_at":"2024-11-13T07:08:24.449Z","updated_at":"2025-05-04T19:34:28.323Z","avatar_url":"https://github.com/neondatabase.png","language":"Python","readme":"# `neon_api`: Python API wrapper for the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-neon-api).\n\n`neon_api` is a Python wrapper designed to simplify interactions with the [Neon API](https://api-docs.neon.tech/reference/getting-started-with-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.\n\nWith `neon_api`, you can automate tasks, streamline workflows, and build powerful integrations with ease.\n\n\n## Installation\n\nInstallation of `neon_api` is easy, with pip:\n\n```bash\n$ pip install neon-api\n```\n\n## Usage\n\n```python\nfrom neon_api import NeonAPI\n\n# Initialize the client.\nneon = NeonAPI(api_key='your_api_key')\n```\n\n**[Documentation is available on ReadTheDocs](https://neon-api-python.readthedocs.io/)**.\n\n\nRemember 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_api.from_environ()`).\n\n\n-------\n\n### Methods of the `NeonAPI` class:\n\n- `me()`: Returns the current user.\n\n**Manage API keys**:\n\n- `api_keys()`: Returns a list of API keys.\n- `api_key_create(**json)`: Creates an API key.\n- `api_key_delete(key_id)`: Deletes a given API key.\n\n**Manage projects**:\n\n- `projects()`: Returns a list of projects.\n- `project(project_id)`: Returns a specific project.\n- `project_create(project_id, **json)`: Creates a new project. \n- `project_update(project_id, **json)`: Updates a given project.\n- `project_delete(project_id)`: Deletes a given project.\n- `project_permissions(project_id)`: Returns a list of permissions for a given project.\n- `project_permissions_grant(project_id, **json)`: Grant permissions to a given project.\n- `project_permissions_revoke(project_id, **json)`: Revoke permissions from a given project.\n- `connection_uri(project_id, database_name, role_name)`: Returns the connection string for a given project.\n\n**Manage branches**:\n\n- `branches(project_id)`: Returns a list of branches for a given project.\n- `branch(project_id, branch_id)`: Returns a specific branch.\n- `branch_create(project_id, **json)`: Creates a new branch.\n- `branch_update(project_id, branch_id, **json)`: Updates a given branch.\n- `branch_delete(project_id, branch_id)`: Deletes a given branch.\n- `branch_set_as_primary(project_id, branch_id)`: Sets a given branch as primary.\n\n**Manage databases**:\n\n- `databases(project_id, branch_id)`: Returns a list of databases for a given project and branch.\n- `database(project_id, branch_id, database_id)`: Returns a specific database.\n- `database_create(project_id, branch_id, **json)`: Creates a new database.\n- `database_update(project_id, branch_id, **json)`: Updates a given database.\n- `database_delete(project_id, branch_id, database_id)`: Deletes a given database.\n\n**Manage endpoints**:\n\n- `endpoints(project_id, branch_id)`: Returns a list of endpoints for a given project and branch.\n- `endpoint_create(project_id, branch_id, **json)`: Creates a new endpoint.\n- `endpoint_update(project_id, branch_id, endpoint_id, **json)`: Updates a given endpoint.\n- `endpoint_delete(project_id, branch_id, endpoint_id)`: Deletes a given endpoint.\n- `endpoint_start(project_id, branch_id, endpoint_id)`: Starts a given endpoint.\n- `endpoint_suspend(project_id, branch_id, endpoint_id)`: Suspends a given endpoint.\n\n**Manage roles**:\n\n- `roles(project_id, branch_id)`: Returns a list of roles for a given project and branch.\n- `role(project_id, branch_id, role_name)`: Returns a specific role.\n- `role_create(project_id, branch_id, role_name)`: Creates a new role.\n- `role_delete(project_id, branch_id, role_name)`: Deletes a given role.\n- `role_password_reveal(project_id, branch_id, role_name)`: Reveals the password for a given role.\n- `role_password_reset(project_id, branch_id, role_name)`: Resets the password for a given role.\n\n**Manage operations**:\n\n- `operations(project_id)`: Returns a list of operations for a given project.\n- `operation(project_id, operation_id)`: Returns a specific operation.\n\n**Experimental**:\n\n- `consumption()`: Returns a list of project consumption metrics.\n\n\nView the [Neon API documentation](https://api-docs.neon.tech/reference/getting-started-with-neon-api) for more information on the available endpoints and their parameters.\n\n\n## Development\n\nFirst, create a virtual environment, then install the dependencies of the library with `pip`:\n\n```bash\n$ pip install -r requirements.txt\n```\n\nThis will install all the necessary dependencies for development.\n\nTo run the tests, use the following command:\n\n```bash\n# set up a .env file with your API key as per `.env.example`\n$ make test\n```\n\nThe tests don't require an internet connection, as they are mocked using the `pytest-vcr` library. To record new cassettes, use the following command:\n\n```bash\n$ make record\n```\n\nThis will record new cassettes for the tests. Make sure to commit these cassettes along with your changes.\n\n### Updating the schema\n\nIn order to update the Python data types from the OpenAPI schema, you need to:\n\n```\n$ mkdir neon_client/\n$ make schema\n# Now, take `neon_client/schema.py` and replace `neon_api/schema.py` with it.\n# Now, run:\n$ make test\n# You may have to run `make record` to update the fixtures.\n```\n\n## License \u0026 Copyright\n\n[Apache 2.0 Licensed](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethreitz%2Fneon-api-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkennethreitz%2Fneon-api-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkennethreitz%2Fneon-api-python/lists"}