Arctic Shift Documentation

repository·master·Indexed 23 days ago

https://github.com/arthurheitmann/arctic_shift

Project Arctic Shift provides researchers and moderators with access to Reddit data through large data dumps, web interfaces, and a specialized API. The API allows for querying posts, comments, subreddits, and users, retrieving comment trees, resolving short links, and accessing time series data for global or subreddit-specific counts and scores.

Tokens
10.3K
Snippets
4
Records
29
Agent score
79%

What's inside Arctic Shift

  1. Understand the structure of auto-generated JSON schemas

    master

    The project provides auto-generated JSON schemas and TypeScript interfaces based on data dumps (from Pushshift and subsequent sources). These schemas are organized into three categories:

    1. Original file schemas: Located under RX/20XX/.... These provide high-fidelity TypeScript interfaces for individual dumps.
    2. Yearly merged schemas: Located under RX/20XX.ts. These merge individual dump schemas for a specific year.
    3. Global merged schemas: Located in RX.ts. These merge all available dumps into a single schema.

    Note that while original file schemas include detailed usage statistics, merged schemas (yearly and global) do not.

  2. Interpret TypeScript interfaces and usage statistics in original schemas

    master

    When using the original dump schemas (found in RX/20XX/...), the TypeScript interfaces include metadata to help you understand data distribution:

    • Optional Fields: Optional fields are marked with a comment indicating frequency, e.g., crosspost_parent?: string, // 628166/16445391 (3.82%). The numbers represent the absolute and relative number of objects containing that field.
    • Multiple Types: If a value can have multiple types, they are sorted by frequency. The first type listed is the most common.

    Accompanying each TypeScript interface is a non-standard JSON file containing detailed statistics, including:

    • Min/max values for integers and floats.
    • Min/max/average lengths for strings and arrays.
    • Number of unique values.
    • Relative usage of each data type.
  3. Understand data accuracy and update latency

    master

    Upvote and Comment Counts

    Data is archived immediately upon posting, meaning score and num_comments may initially be 1 or 0. After approximately 36 hours, all data is updated and should match the values found in the .zst dumps.

    Time Series Accuracy

    Aggregated data in the /api/time_series endpoint might not be 100% accurate and can take a few hours or days to fully update.

  4. Set up Arctic Shift for local data processing

    master

    To process Reddit data dumps locally using the provided helper scripts, follow these steps. Note that you need at least Python 3.10 installed.

    1. Clone the repository including all submodules:
      git clone --recursive https://github.com/ArthurHeitmann/arctic_shift.git
      cd arctic_shift
    2. Install the required dependency zstandard to handle compressed files:
      pip install zstandard
    3. Configure and run the processing script:
      • Open scripts/processFiles.py in your editor.
      • Locate the fileOrFolderPath variable and enter the path to your data file or folder (use raw strings to avoid escaping backslashes).
      • Implement your custom logic inside the processFile function.
      • Run the script and wait for processing to complete.
    git clone --recursive https://github.com/ArthurHeitmann/arctic_shift.git
    cd arctic_shift
    pip install zstandard
  5. Download Arctic Shift archives via Torrents

    master

    Arctic Shift archives are available via torrents on Academic Torrents in two primary formats:

    1. zst: Recompressed zst files. For archives up to 2024-03, these are reformatted and updated with additional data sources. From 2024-04 onwards, archives are released exclusively as zst files.
    2. zst_blocks: The original zst_blocks format. Note that zst_blocks availability was discontinued starting from 2024-04.

    It is requested that users seed the torrents for as long as possible to assist others, as download speeds may be slow shortly after a new release.

    For specific questions regarding zst files, contact u/Watchful1 on Reddit.

  6. Access the Arctic Shift API

    master

    Arctic Shift provides an API for querying Reddit data.

    Base URL: https://arctic-shift.photon-reddit.com Status Page: https://status.arctic-shift.photon-reddit.com Search UI: https://arctic-shift.photon-reddit.com/search

    Note: There are no uptime or performance guarantees.

  7. Handle API rate limiting and query timeouts

    master

    Rate Limiting

    If you receive a 429 error code, you are being rate limited. Limits are calculated dynamically based on load and complexity. To know when you can retry, check the following headers:

    • X-RateLimit-Reset: Seconds until reset.
    • X-RateLimit-Reset-At: Timestamp of the next reset.

    Note: For massive data processing, use the monthly dumps instead of the API.

    Query Timeouts

    If you receive the message "Query timed out", your parameter combination is likely unoptimized. To fix this:

    • Reduce the limit parameter.
    • Use more specific filters like after, before, subreddit, or author.
    • Avoid heavy text searches on body, selftext, or title if possible.
    • Try again after a short delay, as the database may need to 'warm up'.
  8. Retrieve time series data via `/api/time_series`

    master

    Use the /api/time_series endpoint to retrieve aggregated data over time (e.g., post counts or subscriber counts). Note that data may take a few hours or days to fully update and might not be 100% accurate.

    Parameters

    ParameterTypeDefaultNotes
    keystringTime series type or category. See available keys below.
    precisionstringOne of year, quarter, month, week, day, hour, minute.
    afterDateStart date. If not set, the earliest date of the data is used.
    beforeDateEnd date. If not set, the latest date of the data is used.

    Available Keys

    • Global Counts: global/posts/count, global/comments/count (Total posts/comments across Reddit)
    • Global Scores: global/posts/sum_score, global/comments/sum_score (Sum of all upvotes)
    • Global Latency: global/posts/sum_retrieved_after_seconds, global/comments/sum_retrieved_after_seconds (Sum of time between creation and archive)
    • Subreddit Counts: r/<subreddit>/posts/count, r/<subreddit>/comments/count (Posts/comments in a specific subreddit)
    • Subreddit Scores: r/<subreddit>/posts/sum_score, r/<subreddit>/comments/sum_score (Sum of upvotes in a subreddit)
    • Subreddit Subscribers: r/<subreddit>/subscribers (Number of subscribers in a subreddit
  9. Get user-to-user interactions

    master

    Use the /api/users/interactions/users endpoint to get aggregated counts of interactions between users. An interaction is defined as:

    • Author commented under a post
    • Author commented under a comment
    • Someone replied to author's post
    • Someone replied to author's comment

    Use /api/users/interactions/users/list to list all individual interactions between users.

    Warning: For very active users (e.g., bots), this endpoint may time out. If it does, try narrowing the time range using after and before parameters.

    User to User Parameters

    ParameterTypeDefaultNotes
    authorstringrequired
    subredditstring
    afterDate
    beforeDate
    min_countint (>= 0)Minimum number of interactions
    limitint (>= 1)100empty means no limit (limit=)

    User to Subreddit Parameters

    Use /api/users/interactions/subreddits to see which subreddits a user has been active in. This combines post and comment activity with weighting options.

    ParameterTypeDefaultNotes
    authorstringrequired
    weight_postsfloat1.0
    weight_commentsfloat1.0
    beforeDate
    afterDate
    min_countint (>= 0)
    limitint (>= 1)100empty means no limit (limit=)

    Examples

    # Get all interactions of u/spez, with more than 10 interactions, up until 2017
    /api/users/interactions/users?author=spez&before=2017-01-01&min_count=10
  10. Retrieve items by ID

    master

    Use the ID lookup endpoints to retrieve specific Reddit objects based on their unique identifiers.

    Endpoints:

    • /api/posts/ids
    • /api/comments/ids
    • /api/subreddits/ids
    • /api/users/ids

    Parameters:

    • ids (Required): A comma-separated list of IDs. Maximum limit is 500.
    • md2html (boolean): If true, adds auto-generated selftext_html or body_html fields.
    • fields (string): A comma-separated list of specific fields to return.