# Crystallography API
> Crystal structures as an API — powered by the Crystallography Open Database (COD), the open, public-domain collection of over 500,000 crystal structures of organic, inorganic, metal-organic compounds and minerals. Search the database by chemical formula (any standard casing — TiO2, Al2O3, H2O — is normalised automatically) or by free text over mineral names, titles and comments, then look up any structure to get its full crystallographic data: chemical and cell formula, space group (Hermann-Mauguin and Hall), the complete unit cell (a, b, c, alpha, beta, gamma and volume), the source publication (title, authors, journal, year, DOI) and a link to the CIF file. From quartz, calcite and diamond to anatase, corundum and diopside, it is ideal for materials science, solid-state chemistry, mineralogy, crystallography teaching and research tooling. This is a crystal-structure & materials database — distinct from molecule-property (chemistry / PubChem) and protein-structure (PDB) databases. Open data from the Crystallography Open Database (CC0 / public domain).

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/cod-api/..."
```

## Pricing
- **Free** (Free) — 2,200 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 52,000 calls/Mo, 8 req/s
- **Pro** ($22/Mo) — 240,000 calls/Mo, 20 req/s
- **Mega** ($59/Mo) — 880,000 calls/Mo, 50 req/s

## Endpoints

### Crystallography

#### `GET /v1/search` — Search crystal structures by formula or text

**Parameters:**
- `formula` (query, optional, string) — Chemical formula, any casing (TiO2, Al2O3, H2O) Example: `TiO2`
- `text` (query, optional, string) — Free-text search over minerals, titles and comments
- `limit` (query, optional, string) — Max results (1-100, default 25)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cod-api/v1/search?formula=TiO2"
```

**Response:**
```json
{
    "data": {
        "mode": "formula",
        "count": 25,
        "query": "O2 Ti",
        "total": 39,
        "structures": [
            {
                "url": "https://www.crystallography.net/cod/1010942.html",
                "year": 1924,
                "title": "Zur Kristallstruktur von Anastas und Rutil. (II. Teil. Die Anastasstruktur).",
                "cod_id": "1010942",
                "formula": "O2 Ti",
                "mineral": "Anatase",
                "space_group": "I 41/a m d :1"
            },
            {
                "url": "https://www.crystallography.net/cod/1526931.html",
                "year": 2000,
                "title": "Rietveld analysis of electron powder diffraction data from nanocrystalline anatase, Ti O2",
                "cod_id": "1526931",
                "formula": "O2 Ti",
                "mineral": null,
                "space_group": "I 41/a m d :2"
            },
            {
                "url": "https://www.crystallography.net/cod/1528778.html",
                "year": 2006,
                "title": "Structure of beta - Ti O2",
                "cod_id": "1528778",
                "formula": "O2 Ti",
                "mineral": null,
                "space_group": "C 1 2/m 1"
            },
            {
                "url": "https://www.crystallography.net/cod/1530026.html",
                "year": 1988,
                "title": "Ti O2-II. Ambient pressure and structure refinement",
                "cod_id": "
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/structure` — A crystal structure: cell, space group, citation

**Parameters:**
- `id` (query, optional, string) — A COD id (from /v1/search) Example: `2100348`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cod-api/v1/structure?id=2100348"
```

**Response:**
```json
{
    "data": {
        "structure": {
            "doi": "10.1107/S010876810503747X",
            "url": "https://www.crystallography.net/cod/2100348.html",
            "cell": {
                "a": 7.287,
                "b": 9.2,
                "c": 6.688,
                "beta": 90,
                "alpha": 90,
                "gamma": 90,
                "volume": 448.4
            },
            "year": 2006,
            "title": "Pressure-frozen benzene I revisited",
            "cod_id": "2100348",
            "authors": "Budzianowski, Armand; Katrusiak, Andrzej",
            "cif_url": "https://www.crystallography.net/cod/2100348.cif",
            "formula": "C6 H6",
            "journal": "Acta Crystallographica Section B",
            "mineral": null,
            "space_group": "P b c a",
            "cell_formula": "C24 H24",
            "space_group_hall": "-P 2ac 2ab"
        }
    },
    "meta": {
        "timestamp": "2026-06-01T16:23:15.049Z",
        "request_id": "dee10794-9954-4650-9f50-7968f026293c"
    },
    "status": "ok",
    "message": "Structure retrieved",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Endpoint catalogue & notes

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cod-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "COD (the Crystallography Open Database) is the open, public-domain collection of crystal structures of organic, inorganic, metal-organic compounds and minerals — over 500,000 entries, each with unit-cell parameters, a space group, a chemical formula and the publication it came from. /v1/search?formula=TiO2 = find structures by chemical formula (any standard casing — TiO2, Al2O3, H2O — is normalised to COD's alphabetical form), or /v1/search?text=quartz = free-text search over mineral names, titles and comments; both return each match's COD id (e.g. 2100348), formula, mineral, space group and year. /v1/structure?id=2100348 = a single structure's crystallographic data — chemical and cell formula, space group (Hermann-Mauguin and Hall), full unit cell (a, b, c, alpha, beta, gamma and volume), the source publication (title, authors, journal, year, DOI) and links to the CIF file. Get a COD id from /v1/search. Data from the Crystallography Open Database (CC0 / public domain). A crystal-structure & materials database — distinct from molecule-property (chemistry/PubChem), protein-structure (PDB) and sequence databases. Ideal for materials science, solid-state chemistry, mineralogy and education.",
        "source": "Crystallography Open Database (crystallography.net)",
        "endpoints": [
            "/v1/search",
            "/v1/structure",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-01T16:23:15.1
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/cod-api
OpenAPI spec: https://www.oanor.com/api/cod-api/openapi.json
