API Reference

Complete reference for all ZineCore2 API endpoints

The ZineCore2 API provides RESTful endpoints for managing zine metadata, agents, holdings, and repositories. All endpoints support multiple output formats via content negotiation.

Base URL

http://localhost:8000/api/

Production: Replace with your server's domain.


Authentication

Public Read Access

All GET requests are public (no authentication required):

# Public - works without authentication
curl http://localhost:8000/api/zines/
curl http://localhost:8000/api/agents/

Authenticated Write Access

POST, PUT, PATCH, DELETE require authentication:

# Get token
curl -X POST http://localhost:8000/api/auth/token/ \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "yourpassword"}'

# Returns: {"token": "abc123..."}

# Use token for writes
curl -X POST http://localhost:8000/api/zines/ \
  -H "Authorization: Token abc123..." \
  -H "Content-Type: application/json" \
  -d '{"zine_id": "zine_001", ...}'

Learn more about authentication →


Endpoints Overview

Profile Endpoints

    • Zines — ZineCore2 bibliographic records
    • Agents — AgentCore2 authority records
    • Holdings — HoldingCore2 holdings records
    • Repositories — RepoCore2 institutional records

Vocabulary Endpoints

GET /api/vocabularies/subjects/
GET /api/vocabularies/genres/
GET /api/vocabularies/agent-kinds/
GET /api/vocabularies/agent-roles/
GET /api/vocabularies/repository-kinds/
GET /api/vocabularies/access-status/
GET /api/vocabularies/rights-status/
GET /api/vocabularies/formats/

Read-only — vocabularies loaded via fixtures.

Geographic Endpoints

GET /api/geography/places/
GET /api/geography/countries/
GET /api/geography/languages/

Read-only — geographic data loaded via management commands.


Common Patterns

List Resources

Get paginated list of resources:

GET /api/zines/
GET /api/agents/
GET /api/holdings/
GET /api/repositories/

Response format:

{
  "count": 142,
  "next": "http://localhost:8000/api/zines/?page=2",
  "previous": null,
  "results": [
    {
      "zine_id": "zine_mutate_3_1st",
      "title": "Mutate Zine #3",
      ...
    },
    ...
  ]
}

Pagination:

  • Default: 25 items per page
  • Override: ?page_size=50 (max 100)
  • Navigate: Use next and previous URLs

Retrieve Resource

Get single resource by external ID:

GET /api/zines/{zine_id}/
GET /api/agents/{agent_id}/
GET /api/holdings/{holding_id}/
GET /api/repositories/{repo_id}/

Example:

curl http://localhost:8000/api/zines/zine_mutate_3_1st/

Response:

{
  "zine_id": "zine_mutate_3_1st",
  "title": "Mutate Zine #3",
  "creator": [
    {
      "agent_id": "agent_judith_arcana",
      "display_name": "Judith Arcana",
      "kind": "Person"
    }
  ],
  ...
}

Create Resource

Create new resource with POST:

POST /api/zines/
POST /api/agents/
POST /api/holdings/
POST /api/repositories/

Example:

curl -X POST http://localhost:8000/api/zines/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "zine_id": "zine_mutate_3_1st",
    "title": "Mutate Zine #3",
    "creator": ["agent_judith_arcana"],
    "subject": ["feminism"],
    "genre": ["personal-zine"],
    "date": ["2024"],
    "language": ["en"],
    "rights": ["cc-by-4.0"]
  }'

Response (201 Created):

Returns full object with all fields resolved.

Update Resource

Update resource with PUT (full replacement) or PATCH (partial update):

PUT /api/zines/{zine_id}/       # Replace entire resource
PATCH /api/zines/{zine_id}/     # Update specific fields

PATCH example:

curl -X PATCH http://localhost:8000/api/zines/zine_mutate_3_1st/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "abstract": "Updated description",
    "number_of_pages": "36"
  }'

Only provided fields are updated.

Delete Resource

Delete resource with DELETE:

DELETE /api/zines/{zine_id}/
DELETE /api/agents/{agent_id}/
DELETE /api/holdings/{holding_id}/
DELETE /api/repositories/{repo_id}/

Example:

curl -X DELETE http://localhost:8000/api/zines/zine_mutate_3_1st/ \
  -H "Authorization: Token YOUR_TOKEN"

Response: 204 No Content

Cascade behavior:

  • Deleting a zine deletes all its holdings
  • Deleting a repository deletes all its holdings

Content Negotiation

The API supports 7 output formats via HTTP Accept header:

FormatAccept HeaderUse Case
JSONapplication/jsonDefault, API clients
JSON-LDapplication/ld+jsonLinked Data
CSVtext/csvSpreadsheets, bulk export
DC XMLapplication/xmlDublin Core XML
RDF/Turtletext/turtleSemantic web
BibTeXapplication/x-bibtexCitation management
MARCXMLapplication/marcxml+xmlLibrary systems

Example:

# Get zine as JSON-LD
curl -H "Accept: application/ld+json" \
  http://localhost:8000/api/zines/zine_mutate_3_1st/

# Export all zines as CSV
curl -H "Accept: text/csv" \
  http://localhost:8000/api/zines/ > zines.csv

# Get zine as BibTeX
curl -H "Accept: application/x-bibtex" \
  http://localhost:8000/api/zines/zine_mutate_3_1st/

Learn more about output formats →


Filter by Field

Filter list endpoints by field values:

# Zines by subject
GET /api/zines/?subject=feminism

# Zines by genre
GET /api/zines/?genre=personal-zine

# Zines by creator
GET /api/zines/?creator=agent_judith_arcana

# Repositories by country
GET /api/repositories/?country=US

# Holdings by repository
GET /api/holdings/?repository_id=repo_barnard

Full-text search across multiple fields:

# Search zines by title/abstract
GET /api/zines/?search=mutate

# Search agents by name
GET /api/agents/?search=arcana

Ordering

Sort results by field:

# Sort zines by title
GET /api/zines/?ordering=title

# Sort descending (newest first)
GET /api/zines/?ordering=-created_at

Combining Filters

Combine multiple filters:

GET /api/zines/?subject=feminism&genre=personal-zine&ordering=-created_at

Learn more about filtering →


Pagination

All list endpoints are paginated (25 items per page by default).

Response structure:

{
  "count": 142,
  "next": "http://localhost:8000/api/zines/?page=2",
  "previous": null,
  "results": [...]
}

Fields:

  • count — Total number of results
  • next — URL to next page (null if last page)
  • previous — URL to previous page (null if first page)
  • results — Array of resources

Navigate pages:

# Page 1 (default)
GET /api/zines/

# Page 2
GET /api/zines/?page=2

# Custom page size (max 100)
GET /api/zines/?page_size=50

Disable pagination (use with caution):

GET /api/zines/?page_size=1000000

Not recommended for large datasets.


Error Responses

400 Bad Request

Validation errors:

{
  "title": ["This field is required."],
  "creator": ["This field is required."],
  "subject": ["Invalid subject codes: invalid-code"]
}

Fix: Correct the request data.

401 Unauthorized

Missing authentication:

{
  "detail": "Authentication credentials were not provided."
}

Fix: Include Authorization: Token YOUR_TOKEN header.

403 Forbidden

Insufficient permissions:

{
  "detail": "You do not have permission to perform this action."
}

Fix: Use an account with appropriate permissions.

404 Not Found

Resource doesn't exist:

{
  "detail": "Not found."
}

Fix: Check the resource ID.

405 Method Not Allowed

Invalid HTTP method:

{
  "detail": "Method \"DELETE\" not allowed."
}

Fix: Use correct HTTP method for endpoint.

500 Internal Server Error

Server error (check logs):

{
  "detail": "Internal server error"
}

Fix: Check server logs, report bug if needed.


Rate Limiting

Default: No rate limiting in development.

Production: Configure rate limiting in Django settings:

# settings/production.py
REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_CLASSES': [
        'rest_framework.throttling.AnonRateThrottle',
        'rest_framework.throttling.UserRateThrottle'
    ],
    'DEFAULT_THROTTLE_RATES': {
        'anon': '100/hour',
        'user': '1000/hour'
    }
}

Response when throttled (429 Too Many Requests):

{
  "detail": "Request was throttled. Expected available in 3600 seconds."
}

CORS

Development: CORS allowed from all origins.

Production: Configure allowed origins:

# .env
CORS_ALLOWED_ORIGINS=https://yourfrontend.com,https://www.yourfrontend.com

Allowed methods: GET, POST, PUT, PATCH, DELETE, OPTIONS

Allowed headers: Authorization, Content-Type, Accept


Browsable API

Visit any endpoint in a web browser to use the Django REST Framework browsable API:

http://localhost:8000/api/
http://localhost:8000/api/zines/
http://localhost:8000/api/agents/

Features:

  • Interactive forms for POST/PUT/PATCH
  • Authentication via session
  • Syntax-highlighted responses
  • Documentation links

Use for:

  • API exploration
  • Manual testing
  • Debugging

OpenAPI Schema

Get the OpenAPI 3.0 schema:

GET /api/schema/

Formats:

  • JSON: /api/schema/?format=json
  • YAML: /api/schema/?format=yaml

Use with:

  • Swagger UI
  • Postman
  • API client generators

Quick Reference

Zines

MethodEndpointDescription
GET/api/zines/List zines
POST/api/zines/Create zine
GET/api/zines/{zine_id}/Get zine
PUT/api/zines/{zine_id}/Replace zine
PATCH/api/zines/{zine_id}/Update zine
DELETE/api/zines/{zine_id}/Delete zine

Agents

MethodEndpointDescription
GET/api/agents/List agents
POST/api/agents/Create agent
GET/api/agents/{agent_id}/Get agent
PUT/api/agents/{agent_id}/Replace agent
PATCH/api/agents/{agent_id}/Update agent
DELETE/api/agents/{agent_id}/Delete agent

Holdings

MethodEndpointDescription
GET/api/holdings/List holdings
POST/api/holdings/Create holding
GET/api/holdings/{holding_id}/Get holding
PUT/api/holdings/{holding_id}/Replace holding
PATCH/api/holdings/{holding_id}/Update holding
DELETE/api/holdings/{holding_id}/Delete holding

Repositories

MethodEndpointDescription
GET/api/repositories/List repositories
POST/api/repositories/Create repository
GET/api/repositories/{repo_id}/Get repository
PUT/api/repositories/{repo_id}/Replace repository
PATCH/api/repositories/{repo_id}/Update repository
DELETE/api/repositories/{repo_id}/Delete repository

Vocabularies (Read-Only)

MethodEndpointDescription
GET/api/vocabularies/subjects/List subjects
GET/api/vocabularies/subjects/{code}/Get subject
GET/api/vocabularies/genres/List genres
GET/api/vocabularies/agent-kinds/List agent kinds
GET/api/vocabularies/agent-roles/List agent roles
GET/api/vocabularies/repository-kinds/List repository kinds
GET/api/vocabularies/access-status/List access statuses
GET/api/vocabularies/rights-status/List rights statements
GET/api/vocabularies/formats/List formats

Next Steps

Explore detailed documentation for each endpoint:

Ready to use the API? Start with the Zines API reference for complete examples.
Copyright ©2026 ZineCore2 Contributors,