Skip to content

Repository files navigation

 __ __ _ ____ ____ _ __
| \/ | ___ ___ ___ __ _ _ __(_) / ___|| _ \| |/ /
| |\/| |/ _ \/ __/ __|/ _` | '__| | \___ \| | | | ' / | | | | __/\__ \__ \ (_| | | | | ___) | |_| | . \ |_| |_|\___||___/___/\__,_|_| |_| |____/|____/|_|\_\

This repository defines the OpenAPI specifications and types for the official TypeScript SDK. The purpose of the SDK is to provide a type-safe, intuitive interface for accessing Messari's suite of crypto data and AI services.

Project Structure

The repository is organized as follows:

  • packages/api: The SDK package that we publish to npm for consumption.
  • packages/examples: A demo project that implements examples of the SDK in action for the various services: AI, Asset, Intel, News, etc.
  • typegen: The OpenAPI specifications and type generation scripts. Used for updating the SDK types and operations.
├── packages/
│ └── api/
│ └── src/
│ ├── types.ts # Generated API types from OpenAPI
│ ├── schema.ts # Re-exported schema types
│ └── index.ts # Generated operations and re-exports
│ └── examples/
│ └── src/
│ ├── ai.ts # Example usage of the AI service
│ ├── asset/
│ ├── asset.ts # Example usage of the Asset service
│ ├── ath.ts # Example usage of the Asset service - ATHs
│ ├── roi.ts # Example usage of the Asset service - ROIs
├── typegen/
│ ├── openapi/
│ │ ├── common/ # Shared OpenAPI components
│ │ ├── services/ # Service-specific OpenAPI specs
│ │ ├── index.yaml # Main entry point that combines all services
│ │ └── dist/ # Bundled OpenAPI specs
│ └── scripts/ # Type generation scripts
└── package.json

API Services & Implementation Status

List of services currently implemented in the SDK, more services will be added over time. For the full list of APIs, see the API Reference Docs.

Service NameEndpoint NameEndpoint RouteImplemented
AIChat Completion/ai/v1/chat/completions
AIEntity Extraction/ai/v1/classification/extraction
NetworksNetworks/metrics/v1/networks
NetworksNetwork Details/metrics/v1/networks/{networkIdentifier}
NetworksNetwork Metrics/metrics/v1/networks/metrics
NetworksNetwork Timeseries/metrics/v1/networks/{entityIdentifier}/metrics/{datasetSlug}/time-series/{granularity}
IntelEvents/intel/v1/events🚧
IntelEvents By ID/intel/v1/events/{eventId}🚧
IntelIntel Assets/intel/v1/assets🚧
NewsNews Assets/news/v1/news/assets🚧
NewsNews Feed/news/v1/news/feed🚧
NewsNews Sources/news/v1/news/sources🚧
AI DigestProject Recap By ID/ai-digest/api/v1/recap
AI DigestExchange Recaps Overview/ai-digest/api/v1/exchange-rankings-recap
AI DigestExchange Recap By ID/ai-digest/api/v1/exchange-recap
ResearchReports/research/v1/reports🚧
ResearchReport By ID/research/v1/reports/{id}🚧
ResearchReport Tags/research/v1/reports/tags🚧
DiligenceReport Preview/diligence/v1/reports/preview🚧
DiligenceReport By Asset ID/diligence/v1/report/asset/{assetId}🚧
FundraisingFunding Rounds/funding/v1/rounds🚧
FundraisingFunding Rounds Investors/funding/v1/rounds/investors🚧
FundraisingMergers and Acquisitions/funding/v1/mergers-and-acquisitions🚧
FundraisingOrganizations/funding/v1/organizations🚧
FundraisingProjects/funding/v1/projects🚧

Generating Types

To regenerate types after modifying OpenAPI specs:

# Install dependencies
pnpm install
# Generate types & build the SDK
pnpm run api:build

Using the SDK

For detailed SDK usage, see the README.

⚠️ Important Type Generation Rules

  1. Never run type generation scripts directly. Always use the package.json scripts from the root directory:

    pnpm api:build
  2. Service Registration: When creating a new service, you must register it in typegen/openapi/index.yaml:

    • Add paths to your service's endpoints
    • Add tags for your service
    • Reference your service's OpenAPI file
  3. Schema Name Uniqueness: Schema names must be unique across all services. Since all schemas are combined into a single namespace, duplicate names will cause conflicts.

    • Example: If intel service has an Asset schema and news service also has an Asset schema, they will conflict
    • Solution: Use service-specific prefixes (e.g., NewsAsset vs IntelAsset)
  4. Common Components: Use the common components in typegen/openapi/common/ for shared schemas:

    • PaginationResult for pagination metadata
    • APIResponseWithMetadata for standard response wrapper
    • APIError for error responses
  5. DRY Principle: Don't repeat common schemas in service-specific files. Instead, reference them:

    PaginationResult:
    $ref: '../../common/components.yaml#/components/schemas/PaginationResult'
  6. Handling Type Collisions: When multiple services define types with the same name:

    • For identical types used across services: Move these to /openapi/common/components.yaml
    • For different types with the same name: Use service-specific prefixes (e.g., IntelAsset vs NewsAsset)
  7. Common Issues:

    • Missing pagination parameters: Ensure referenced parameters are properly handled in the generation scripts
    • Type mismatches: Verify OpenAPI specs and run pnpm api:build to regenerate all types

For more detailed information on the type generation process, see the Type Generation README.

License

MIT License - see the LICENSE file for details.

Support

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages