Skip to main content

Corpus Product API Integration Guide

This guide provides everything you need to integrate with the Intrace Corpus Product API.

Getting Started

1. Obtain API Key

Contact your Intrace representative to receive an API key. The API key is required for all requests.

2. Base URLs

Production: https://api.corpus.intrace.ai Development: http://localhost:8000 (for testing)

3. Authentication

All requests must include your API key in the X-API-Key header:

Common Use Cases

Available Event Filters

The /v1/events endpoint supports the following filter parameters: Categorical filters — all accept multiple values (repeat the parameter to filter by multiple values):
  • event_category - Filter by category (e.g., “conflict”, “cyber”, “crime”)
  • event_type - Filter by type within a category
  • event_subtype - Filter by subtype within a type
  • country - Filter by country code
Date filters:
  • date_from - Inclusive start date (YYYY-MM-DD)
  • date_to - Inclusive end date (YYYY-MM-DD)
Numeric range filters:
  • salience_score_min / salience_score_max - Filter by salience score
  • article_count_min / article_count_max - Filter by number of source articles
  • actor_count_min / actor_count_max - Filter by number of actors involved
Text search:
  • search - Full-text search across title and description
Sorting:
  • sort_by - Sort column: event_date (default), salience_score, article_count, title, created_at
  • sort_order - Sort direction: “asc” or “desc” (default: “desc”)
Note: An unrecognised sort_by value silently falls back to event_date. No validation error is returned — double-check spellings if results appear sorted unexpectedly.

Multi-Value Filtering

Categorical filters (event_category, event_type, event_subtype, country) accept multiple values by repeating the parameter:

Query Events by Category

Filter events by category to focus on specific domains:

Filter by Date Range

Get events within a specific time period:

Search Events

Search across event titles and descriptions:

Get Event Details

Retrieve full details including category-specific data:

Export Data

Export filtered events in various formats:

Discover Filter Values

Use metadata endpoints to find valid filter values:

Available Actor Filters

The /v1/actors endpoint supports: Categorical filters (multi-value, repeat parameter for multiple values):
  • actor_type - Filter by actor category (e.g., “rebel_group”, “state_government”)
  • country - Filter by actor’s primary country
Numeric range filters:
  • event_count_min / event_count_max - Filter by number of events the actor appears in
  • article_count_min / article_count_max - Filter by number of source articles
Text search:
  • search - Search in canonical actor name
Sorting:
  • sort_by - Sort column: canonical_name (default), event_count, article_count, created_at
  • sort_order - Sort direction: “asc” (default) or “desc”
Note: An unrecognised sort_by value silently falls back to canonical_name. No validation error is returned. The /v1/actors/{id}/events endpoint accepts the same filter and sort parameters as /v1/events.

Pagination Best Practices

Handle large result sets with pagination:

Paginating Actors

The same pagination pattern applies to actors:

End-to-End Workflow Example

This example shows a complete analyst workflow: discover valid filter values, query high-salience conflict events in a region, then pull the event history for the most active actor involved.

Code Examples

Python

Complete example using the requests library:

JavaScript/TypeScript

Example using fetch API. Note that multi-value filters require append not set on URLSearchParams:

cURL

Basic cURL examples:

Export Formats

CSV Format

Comma-separated values with headers. Suitable for spreadsheet analysis.
  • Use case: Import into Excel, Google Sheets, or data analysis tools
  • File extension: .csv
  • MIME type: text/csv

JSON Format

Array of complete event objects with actors and metadata.
  • Use case: Programmatic processing, full data fidelity
  • File extension: .json
  • MIME type: application/json

GeoJSON Format

Geographic data format following RFC 7946 specification.
  • Use case: Mapping applications, GIS tools, Leaflet/Mapbox
  • File extension: .geojson
  • MIME type: application/geo+json

ACLED Format

Compatible with ACLED (Armed Conflict Location & Event Data Project) schema. Only available for conflict category events.
  • Use case: Integration with existing ACLED workflows and tools
  • File extension: .json
  • MIME type: application/json
Actor Position Fields:
  • actor1, actor2: Principal and secondary actors
  • assoc_actor_1, assoc_actor_2: Internal sub-units (semicolon-separated)
  • supporting_actor_1, supporting_actor_2: External supporting actors (comma-separated)
  • inter1, inter2: Inter-group codes (1=state, 2=rebel, 3=political militia, etc.)
  • interaction: Combined interaction code (e.g., “1-2” for state vs rebel)
Example:

Flat Format

Denormalized JSON with actor positions as explicit columns, suitable for spreadsheet import and tabular analysis.
  • Use case: Spreadsheet import where actor relationships need to be explicit
  • File extension: .json
  • MIME type: application/json
Actor Position Columns:
  • principal_actor, secondary_actor: Main actors
  • principal_actor_category, secondary_actor_category: Actor categories (state_forces, rebel_group, etc.)
  • sub_principal_actors, sub_secondary_actors: Internal sub-units (semicolon-separated)
  • supporting_principal_actor, supporting_secondary_actor: External supporting actors (comma-separated)
Key Distinction:
  • Sub-actors: Internal organizational units (e.g., “7th Division” within “Nigerian Army”)
  • Supporting actors: External organizations providing support (e.g., “U.S. Special Forces” supporting “Colombian Army”)
Example:

Error Handling

The API uses standard HTTP status codes. All error responses share the same body shape:
401 responses are returned when the X-API-Key header is absent, empty, or does not match any active key. There is no distinction between a missing and an invalid key in the response body. 422 responses are returned for type validation failures (e.g., passing "abc" as article_count_min). They do not fire for unrecognised categorical values — passing an unknown event_category returns an empty result set, not an error. Silent fallbacks — two parameters degrade gracefully instead of returning 422:
  • An unrecognised sort_by value silently falls back to the default sort column for that endpoint (event_date for events, canonical_name for actors).

Rate Limits

Default rate limits:
  • 100 requests per minute per API key
  • 10,000 requests per day per API key
The API does not currently return rate limit headers (X-RateLimit-Remaining, Retry-After). Implement exponential backoff on 429 responses rather than relying on header-based scheduling.
Contact support if you need higher limits for your use case.

Next Steps