Skip to main content

Latest version on PyPI Supported python versions for civis-python CircleCI build status Documentation Status

The Civis API Python client is a Python package that helps analysts and developers interact with Civis Platform programmatically. The package includes a set of tools around common workflows as well as a convenient interface to make requests directly to the Civis API.

Please see the full documentation for more details.

API Keys

In order to make requests to the Civis API, you will need a Civis Platform API key that is unique to you. Instructions for creating a new key are found here. API keys have a set expiration date and new keys will need to be created at least every 30 days. The API client will look for a CIVIS_API_KEY environment variable to access your API key, so after creating a new API key, follow the steps below for your operating system to set up your environment.

Linux / MacOS

  1. Add the following to your shell configuration file (~/.zshrc for MacOS or ~/.bashrc for Linux, by default):

    export CIVIS_API_KEY="alphaNumericApiK3y"
  2. Source your shell configuration file (or restart your terminal).

Windows

  1. Navigate to “Settings” -> type “environment” in search bar -> “Edit environment variables for your account”. This can also be found in “System Properties” -> “Advanced” -> “Environment Variables…”.

  2. In the user variables section, if CIVIS_API_KEY already exists in the list of environment variables, click on it and press “Edit…”. Otherwise, click “New..”.

  3. Enter CIVIS_API_KEY as the “Variable name”.

  4. Enter your API key as the “Variable value”. Your API key should look like a long string of letters and numbers.

Installation

After creating an API key and setting the CIVIS_API_KEY environment variable, install the Python package civis with the recommended method via pip:

pip install civis

Alternatively, if you are interested in the latest functionality not yet released through pip, you may clone the code from GitHub and build from source (git assumed to be available):

pip install git+https://github.com/civisanalytics/civis-python.git

You can test your installation by running

import civis
client = civis.APIClient()
print(client.users.get_me()['username'])

If civis was installed correctly, this will print your Civis Platform username.

The client has a soft dependency on pandas or polars to support dataframes. If you are using the civis.io namespace to read or write data from Civis, it is highly recommended that you install pandas or polars and set the argument return_as to "pandas" or "polars", respectively, in functions that accept that parameter. To install pandas:

pip install pandas

To install polars:

pip install polars

Machine learning features in the ml namespace have a soft dependency on scikit-learn and pandas. Install scikit-learn to export your trained models from the Civis Platform or to provide your own custom models. Use pandas to download model predictions from the Civis Platform. The civis.ml code optionally uses the feather format to transfer data from your local computer to Civis Platform. Install these dependencies with

pip install scikit-learn
pip install pandas
pip install feather-format

Some CivisML models have open-source dependencies in addition to scikit-learn, which you may need if you want to download the model object. These dependencies are civisml-extensions, glmnet, and muffnn. Install these dependencies with

pip install civisml-extensions
pip install glmnet
pip install muffnn

Usage

civis includes a number of wrappers around the Civis API for common workflows.

import civis
df = civis.io.read_civis(table="my_schema.my_table",
                         database="database",
                         return_as="pandas")

The Civis API may also be directly accessed via the APIClient class.

import civis
client = civis.APIClient()
database = client.databases.list()

See the documentation for a more complete user guide.

Building Documentation

Background:

  • We use the Sphinx framework. The documentation source files are in docs/.

  • All auto-generated files, including the HTML pages, are explicitly not versioned (see .gitignore).

For the public documentation at https://civis-python.readthedocs.io:

  • The doc build is configured by .readthedocs.yaml. Normally, even when we need to update the documentation or make a new release of civis-python, neither this configuration YAML file nor Civis’s account on the Read the Docs site need any updates.

  • To update the documentation, the files under docs/ can be updated as needed. If the “API Resources” pages need to be updated because the upstream Civis API has been updated, then the following need to happen: (i) the new Civis API updates must be accessible by a “standard” Civis Platform user, i.e., not behind a feature flag, and (ii) you’ll need to locally run python tools/update_civis_api_spec.py to update civis_api_spec.json inside the civis Python package codebase. It is this JSON file that’s the basis for the Civis API information on the “API Resources” pages. Regardless of which Civis API key you use to run python tools/update_civis_api_spec.py, the updated civis_api_spec.json only contains Civis API information available to a standard Civis Platform user.

  • The URL https://civis-python.readthedocs.io auto-redirects to the “stable” URL https://civis-python.readthedocs.io/en/stable/ which reflects the most recent released civis-python version (every GitHub release with the tag “vX.Y.Z” triggers a new “stable” doc build on the Read The Docs site). In contrast, the “latest” URL https://civis-python.readthedocs.io/en/latest/ reflects the most recent commit to the upstream main branch of the civis-python codebase on GitHub. If there are doc changes (e.g., new or removed Civis API methods) that we’d really like to show up at the “stable” URL sooner rather than waiting for the next release with other code changes, we can make a patch release (i.e., increment the “Z” in “vX.Y.Z”).

The doc build has its full dependencies listed in docs/requirements.txt. To update this file:

  • Set up a [uv](https://docs.astral.sh/uv/)-based virtual environment, as documented in [CONTRIBUTING.md](CONTRIBUTING.md).

  • Run the uv pip compile command at the top of docs/requirements.txt, with the flag --upgrade added to upgrade all transitive dependencies as well (which is necessary to resolve security vulnerabilities flagged for some of these transitive dependencies from time to time).

To build the documentation locally, for testing and development:

  • Install the full doc-related dependencies: pip install -r docs/requirements.txt.

  • Run sphinx-build -b html docs docs/build. In case you would like for the “API Resources” page to locally show what a specific Civis Platform user would see from the Civis API (rather than use the available civis_api_spec.json for a standard Civis Platform user), set the environment variable CIVIS_API_KEY to this user’s key and prepend this command with FETCH_REMOTE_RESOURCES=true.

  • Note that docs/conf.py generates the API reference source files as part of the build: one page per endpoint (docs/api_<endpoint>_endpoint.rst) and one page per endpoint method (docs/api_<endpoint>/<method>.rst, roughly 900 of them). They are all gitignored. If you switch between branches that generate different sets of pages, delete docs/build first so that Sphinx doesn’t leave stale HTML behind.

Command-line Interface (CLI)

After installing the Python package, you’ll also have a civis command accessible from your shell. It surfaces a commandline interface to all of the regular Civis API endpoints, plus a few helpers. To get started, run civis --help. Please see the CLI documentation for more details.

Contributing

See CONTRIBUTING.md for information about contributing to this project.

License

BSD-3

See LICENSE.md for details.

For Maintainers

The tools directory contains scripts that civis-python maintainers can use (and maintain…). Please see their docstrings for usage. Non-public information can be found by searching the internal documentation system or consulting the current maintainers.

Release files for civis 2.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for civis 2.10.0
File Size Uploaded
civis-2.10.0.tar.gz 608.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for civis 2.10.0
File Interpreter ABI Platform
civis-2.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / civis-2.10.0.tar.gz

Download URL civis-2.10.0.tar.gz
Size 608.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ed95483df81fe429ba9433d7f8eac1a5d883e09e710481de01622bcd400c909d
BLAKE2b-256 checksum
How to use checksums
9f24be152b89b99bf4a247324d95b7b769bf1ebddb52535273c0564bd750b358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / civis-2.10.0-py3-none-any.whl

Download URL civis-2.10.0-py3-none-any.whl
Size 573.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f640650f145149f351844034a2d2d5922cae21656abeb5753661c7a26e97d21
BLAKE2b-256 checksum
How to use checksums
6d813c13416d577651b2f57e05035e5856b1c5018874ce41ecc4dac33f83a855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.10.0 This release

2 release files

2.9.3

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.16.1

2 release files

1.16.0

2 release files

1.15.1

2 release files

1.15.0

2 release files

1.14.1

2 release files

1.14.0

2 release files

1.12.1

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

1 release file

1.9.0

1 release file

1.8.1

2 release files

1.8.0

1 release file

1.7.2

1 release file

1.7.1

1 release file

1.6.2

2 release files

1.6.1

1 release file

1.6.0

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page