| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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.
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.
Note
Treat your API key like a password. Do not keep it under version control or share it with others.
Add the following to your shell configuration file (~/.zshrc for MacOS or ~/.bashrc for Linux, by default):
export CIVIS_API_KEY="alphaNumericApiK3y"
Source your shell configuration file (or restart your terminal).
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.gitYou 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 pandasTo install polars:
pip install polarsMachine 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-formatSome 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 muffnncivis 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.
Background:
For the public documentation at https://civis-python.readthedocs.io:
The doc build has its full dependencies listed in docs/requirements.txt. To update this file:
To build the documentation locally, for testing and development:
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.
See CONTRIBUTING.md for information about contributing to this project.
BSD-3
See LICENSE.md for details.
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.
| Back | FazBrowse Home | New Git URL |