Skip to main content

A Python package for interfacing with the Mozilla Data Collective's API

Project description

Mozilla Data Collective Python API Library

Python library for interfacing with the Mozilla Data Collective REST API.

Installation

Install the package using pip:

pip install datacollective

Quick Start

  1. Get your API key from the Mozilla Data Collective dashboard

  2. Set up your environment:

    # Copy the example environment file
    cp .env.example .env
    
  3. Configure your API key by editing .env:

    # Required: Your MDC API key
    MDC_API_KEY=your-api-key-here
    
    # Optional: Download path for datasets (defaults to ~/.mozdata/datasets)
    MDC_DOWNLOAD_PATH=~/.mozdata/datasets
    
  4. Start using the library:

    from datacollective import DataCollective
    
    # Initialize the client
    client = DataCollective()
    
    # Download a dataset
    client.get_dataset('mdc-dataset-id')
    

Configuration

The client loads configuration from environment variables or .env files:

  • MDC_API_KEY - Your Mozilla Data Collective API key (required)
  • MDC_API_URL - API endpoint (defaults to production)
  • MDC_DOWNLOAD_PATH - Where to download datasets (defaults to ~/.mozdata/datasets)

Environment Files

Create a .env file in your project root:

# MDC API Configuration
MDC_API_KEY=your-api-key-here
MDC_API_URL=https://datacollective.mozillafoundation.org/api
MDC_DOWNLOAD_PATH=~/.mozdata/datasets

Note: Never commit .env files to version control as they contain sensitive information.

Basic Usage

from datacollective import DataCollective

# Initialize client (loads from .env automatically)
client = DataCollective()

# Verify your configuration
print(f"API URL: {client.api_url}")
print(f"Download path: {client.download_path}")

# Download a dataset
dataset = client.get_dataset('your-dataset-id')

Multiple Environments

You can use different environment configurations:

# Production environment (default, uses .env)
client = DataCollective()

# Development environment (uses .env.development)
client = DataCollective(environment='development')

# Staging environment (uses .env.staging)  
client = DataCollective(environment='staging')

License

This project is released under MPL (Mozilla Public License) 2.0.

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

datacollective-0.0.16.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datacollective-0.0.16-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file datacollective-0.0.16.tar.gz.

File metadata

  • Download URL: datacollective-0.0.16.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for datacollective-0.0.16.tar.gz
Algorithm Hash digest
SHA256 d7982b8b98ead928f069e389b3730eebbde050f5e3f86c09cf8f5a6634662a4e
MD5 d618a6f3164a0896e4f4348e5d4b4d51
BLAKE2b-256 9a477f0603b9d168e954acbd117f57095e098065039d9fdc389c1a72606e7936

See more details on using hashes here.

File details

Details for the file datacollective-0.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for datacollective-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 92a7fb0bf10dea7064a38f2b45d50064c341814662c9921b14387f6c3dc683a4
MD5 0fbf9acec295513dc7bf480cd9e105ef
BLAKE2b-256 3e3850301ce65d4914c17b4fb1eb8aaa2c3f146ed4e841cae0048c80db268e0b

See more details on using hashes here.

Supported by

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