Skip to content

macrocosm-os/macrocosmos-ts

Repository files navigation

Macrocosmos TypeScript SDK

The official TypeScript SDK for Macrocosmos.

Installation

npm install macrocosmos

Usage

Gravity Client

The Gravity client provides an interface for data collection and dataset management.

import { GravityClient } from 'macrocosmos';

// Initialize the client
const client = new GravityClient({ apiKey: 'your-api-key' });

// Create a new gravity task
const task = await client.createGravityTask({
  name: 'My Data Collection Task',
  gravityTasks: [
    { platform: 'x', topic: '#ai' },
    { platform: 'reddit', topic: 'r/ai' }
  ],
  notificationRequests: [
    { type: 'email', address: '[email protected]', redirectUrl: 'https://example.com/datasets' }
  ]
});

// List all gravity tasks
const tasks = await client.getGravityTasks({
  includeCrawlers: true
});

// Get a specific crawler
const crawler = await client.getCrawler({
  crawlerId: 'crawler-id'
});

// Build a dataset from a crawler
const dataset = await client.buildDataset({
  crawlerId: 'crawler-id',
  notificationRequests: [
    { type: 'email', address: '[email protected]' }
  ]
});

// Get a dataset
const datasetStatus = await client.getDataset({
  datasetId: 'dataset-id'
});

// Cancel a gravity task
const cancelResult = await client.cancelGravityTask({
  gravityTaskId: 'task-id'
});

// Cancel a dataset build
const cancelDataset = await client.cancelDataset({
  datasetId: 'dataset-id'
});

SN13 Client

The SN13 client provides an interface for the SN13 Validator API.

import { Sn13Client } from 'macrocosmos';

// Initialize the client
const client = new Sn13Client({apiKey: 'your-api-key'});

// Get the onDemandData response
const response = await client.onDemandData({  
  source: 'x',
  usernames: ['nasa', 'spacex'],
  keywords: ['photo', 'space', 'mars'],
  startDate: '2024-04-01',
  endDate: '2025-04-25',
  limit: 3,
  keywordMode: 'any',
});

About

Macrocosmos TypeScript SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5