Open Sourcing the Civis API Client for Python

December 13, 2016 Keith Ingersoll

We’ve written before about the Civis API and how we’re using it to do some serious data science. With the Civis API, we no longer have to worry about whether we have enough RAM on our laptop to build that intensive model, or whether there’s another job running on our shared server hogging all the processors. It has become an integral component of our operation—so much so that we developed a client library to make it even easier to use. And we’re happy to make this library open-source, so everyone can harness the power of the Civis API in their own custom workflows.

The Civis API Client for Python has a few key features which make working with the Civis API more productive and fun:

1) It’s easy to install: just run pip install civis.

2) The client includes a set of high level functions for common workflows. You can move data to and from the cloud with a single line of code.

import civis
import pandas as pd

# Load data into a Pandas DataFrame
df ="table", database="database", use_pandas=True)

# Upload a Pandas Dataframe to the Cloud Asynchronously, table="new_table", database="database")

3) You can write custom workflows in native Python syntax. The Python client takes care of making the correct HTTP calls and passing parameters. With the special parameter iterator=True, it even stitches together paginated API calls. For example, you can measure just how big your data is:

import civis

client = civis.APIClient()
database_id = client.get_database_id("my_database")
data_mb = 0
tables = client.tables.list(database_id=database_id, iterator=True)
for table in tables:
    data_mb += table["size_mb"] or 0
print("Big Data! {} MB".format(data_mb))

4) There’s Python-specific documentation. You can head to ReadTheDocs to see some more examples and read our detailed documentation.

There you have it—the Civis API Client for Python is open for business. Log into Civis Platform, generate an API key (if you haven’t already), and get started! Oh, and don’t forget to check out our other open source projects.

The post Open Sourcing the Civis API Client for Python appeared first on Civis Analytics.

Previous Article
How We Fine Tuned Lyric Opera’s Marketing Efforts
How We Fine Tuned Lyric Opera’s Marketing Efforts

Like many nonprofits in the arts, Lyric Opera of Chicago faces the familiar challenges of aging audiences, ...

Next Article
Supercharge Your Customer List (for Free)
Supercharge Your Customer List (for Free)

One of the most common requests we get from clients is to help them understand the people they already “kno...