Skip to content

Conversation

@sumulige
Copy link

Pull Request: Add Activity Streams, Intervals, and Bulk Operations Support

Summary

This PR adds support for three important API features that were missing from the client:

  1. Activity Streams - Time-series data access (power, heart rate, cadence, etc.)
  2. Activity Intervals - Lap/interval data management
  3. Bulk Operations - Efficient bulk create/delete/update operations

These features were added to the Intervals.icu API in 2024-2025 and are now available via the REST API.

Changes

New Types Added

  • ActivityStream - Stream data structure
  • StreamType - All available stream types (watts, heartrate, cadence, etc.)
  • StreamsOptions - Options for stream requests
  • UpdateStreamsResult - Stream update response
  • Interval - Interval/lap data
  • IntervalsDTO - Intervals container
  • UpdateIntervalsOptions - Interval update options
  • BulkEventInput - Bulk event input with external_id support
  • DoomedEvent - Event for bulk deletion
  • DeleteEventsResponse - Bulk deletion response

New Client Methods

Activity Streams

  • getActivityStreams() - Get time-series data for activities
  • updateActivityStreams() - Update streams from JSON
  • updateActivityStreamsFromCSV() - Update streams from CSV

Activity Intervals

  • getActivityIntervals() - Get activity intervals/laps
  • updateActivityIntervals() - Update or replace intervals
  • deleteActivityIntervals() - Delete specific intervals
  • splitInterval() - Split an interval at index
  • updateInterval() - Update a specific interval
  • getActivityWithIntervals() - Get activity with intervals included

Bulk Operations

  • createEventsBulk() - Create multiple events at once
  • deleteEventsBulk() - Delete events by ID or external_id
  • deleteEventsRange() - Delete events by date range and category
  • updateEventsRange() - Bulk update events in date range
  • updateWellnessBulk() - Bulk update wellness records

API Documentation References

Example Usage

import { IntervalsClient } from 'intervals-icu';

const client = new IntervalsClient({
  apiKey: process.env.ICU_API_KEY
});

// Get power and heart rate streams
const streams = await client.getActivityStreams(12345, {
  types: ['watts', 'heartrate']
});

// Get activity intervals
const { intervals, count } = await client.getActivityIntervals(12345);

// Create multiple events at once
const events = await client.createEventsBulk([
  {
    start_date_local: '2024-01-15',
    name: 'Morning Workout',
    category: 'WORKOUT',
    external_id: 'workout-001'
  },
  {
    start_date_local: '2024-01-16',
    name: 'Evening Workout',
    category: 'WORKOUT',
    external_id: 'workout-002'
  }
]);

// Delete by external IDs
await client.deleteEventsBulk([
  { external_id: 'workout-001' },
  { external_id: 'workout-002' }
]);

Testing

All existing tests pass (49/49). The changes are fully typed and backward compatible.

Breaking Changes

None. All changes are additive.

Checklist

  • TypeScript types added/updated
  • JSDoc comments added
  • Methods follow existing naming conventions
  • Error handling consistent with existing code
  • Tests pass
  • Build succeeds

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

- Add Activity Streams API (get, update from JSON/CSV)
- Add Activity Intervals API (get, update, delete, split)
- Add Bulk Operations (createEventsBulk, deleteEventsBulk, updateEventsRange, etc.)
- Add comprehensive TypeScript types for new features
- Export new types in index.ts

New methods:
- getActivityStreams(), updateActivityStreams(), updateActivityStreamsFromCSV()
- getActivityIntervals(), updateActivityIntervals(), deleteActivityIntervals()
- splitInterval(), updateInterval(), getActivityWithIntervals()
- createEventsBulk(), deleteEventsBulk(), deleteEventsRange()
- updateEventsRange(), updateWellnessBulk()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants