LogoLogo
Request an API keyBack to Craft.co
  • Introduction
  • About GraphQL
  • Authentication
  • Troubleshooting
  • Company Data API
    • Company Data API Introduction
    • Getting started
      • Getting started with JavaScript
      • Getting started with Python
      • Getting started with Ruby
      • Getting started with cURL
    • Query Parameters
    • Data Categories
      • Basic Company Information
        • USG Prohibited List
        • Security Rating
        • Gov Spending
        • Unspsc Code
        • Patent
        • Stock Market
        • Tag
      • Financials
        • Private Valuation
        • Funding Rounds
        • Income Statement
        • Cash Flow Statement
        • Balance Sheet
        • Revenue Breakdown
        • Acquisitions
        • Analyst Ratings
        • Filing
        • Stock Summary
        • Latest Z Score
        • Ratios
      • Human capital
        • Company Ratings
        • Employee Numbers
        • Human Capital Metrics
        • Job Categories
        • Jobs
        • Key Executives
        • Salaries
      • Operating data
        • Locations
        • Data Breaches
        • Competitors
        • Blacklists
        • Twitter Engagement
        • News Articles
        • Operating Metrics (KPIs)
        • Sentiment Breakdowns
          • Sentiment Breakdown Item
            • Sentiment External Item
        • Sustainability Metrics
        • Technology Stack
        • Twitter Followers
        • Court Filings
        • Patents
        • Products and Services
        • Government Spending
        • Website Traffic
        • Compliance Data
        • Risks
    • GraphQL Enums
      • Unspsc Code Level Enum
      • Company Status Enum
      • Company Type Enum
      • Currency Type Enum
      • Metric Unit Enum
      • Period Type Enum
      • Sentiment Breakdown Type Enum
    • Core data types
      • String
      • Money Object
      • Source Object
      • Image Object
      • Period Object
      • Time Frame
      • AcurisAddress
      • AcurisAlias
      • AcurisBusinessLink
      • AcurisContactEntry
      • AcurisEvidence
      • AcurisGriEntry
      • AcurisIdentifier
      • AcurisIndividualLink
      • AcurisInsEntry
      • AcurisNote
      • AcurisPoiEntry
      • AcurisPosition
      • AcurisRegime
      • AcurisRelEntry
      • AcurisRelEvent
      • AcurisRelEventPeriod
      • AcurisRreEntry
      • AcurisRreEvent
      • AcurisSanEntries
      • AcurisSanEntry
      • AcurisSanEvent
      • AcurisSoeEntry
      • AcurisPepEntry
      • AcurisStatus
      • Risk
      • AdditionalInfo
      • RiskRating
      • RiskHighlight
      • RiskRatingInt
      • RiskRatingIntData
      • RiskRatingIntScaleItem
      • RiskRatingIntValueRange
      • RiskRatingFloat
      • RiskRatingFloatData
      • RiskRatingFloatScaleItem
      • RiskRatingFloatValueRange
      • ColorLinearGradient
      • RiskRatingString
      • RiskRatingStringData
      • RiskRatingStringScaleItem
    • Additional data types
      • PageInfo
    • Query examples
    • Restrictions on Usage
    • Usage
  • Added Companies API
    • Newly Profiled Companies API Introduction
    • Query
      • Basic Company
  • Alerts API
    • Alerts API Introduction
    • Getting started
      • Getting started with JavaScript
      • Getting started with Python
      • Getting started with Ruby
      • Getting started with cURL
    • Alerts API Queries
      • Pagination
      • Filtering and sorting
    • Alerts API Reference
      • Alert Object
      • Filter Object
      • Order Object
      • Payload Object
    • Query examples
    • Restrictions on Usage
Powered by GitBook
On this page

Was this helpful?

  1. Alerts API

Query examples

This page provides additional examples of various queries for Alerts API

Find Alerts for a set of Companies between certain dates

We're using where filter with multiple fields to find all of the Alerts from January 2021 for two given companies. You may find more details about filters in Alerts API in the Filtering and sorting guide.

query findAlerts {
  alerts(
    where: {
      company: {
        id: { in: [334, 1842] }
      },
      publishedAt: {
        gte: "2021-01-01",
        lte: "2021-02-01"
      }
    }
  ) {
    id
    text
    title
    company {
      displayName
    }
  }
}

Find all Alerts from a certain date till now

Such a query might potentially return more entities than allowed per page. Please see the Alerts API pagination guide for more details on how to work with paginated queries.

query findAlerts($after: ID!, $where: AlertBoolExpression!) {
  alerts(
    first: 100,
    after: $after,
    where: $where,
  ) {
    text
    title
    class {
      label
    }
  }
}

where argument could have the following shape:

{
  "publishedAt": { "gt": "2021-01-01" }
}

Fetch all available Alert fields

This query demonstrates all of the fields currently available on the Alert node. You may find the full type definitions available in the Alerts API Reference.

query findAlerts {
  alerts {
    id
    dataset
    polarity
    payload
    class {
      code
      label
    }
    resource {
      id
      type
    }
    title
    text
    source
    value
    variable
    company {
      id
      displayName
      homepage
    }
    period
    publishedAt
    occuredAt
  }
}

Fetch all available Commodity Alerts since the given date

Please, note that particular dataset and class availability depends on your contractual agreement with Craft. Reach out to sales@craft.co for additional details.

This query filters alerts by the dataset and publishedAt fields.

query FetchCommodityAlerts($after: ID!, $where: AlertBoolExpression!) {
  alerts(
    first: 100,
    after: $after,
    where: $where,
  ) {
    text
    polarity
    payload
    resource {
      id
      type
    }
  }
}

where object could have the following shape:

{
  "publishedAt": { "gt": "2022-01-01" },
  "dataset": { "eq": "news_commodities" }
}

The query may return more than 100 records for a single request if there were more Alerts published during the given period of time. In order to fetch all of the records, please refer to the Alerts Pagination Guide.

You may also apply additional filters and sorting order if needed.

Filter Alerts by Polarity

This query shows how to find Alerts that have certain intent or sentiment (positive, negative or neutral) associated with them.

polarity field is an Int where all the values below 0 represent a negative sentiment and all values above - represent a positive one.

query FetchAlertsByPolarity {
  positiveAlerts: alerts(
    where: {
      polarity: {
        gt: 0
      }
    }
  ) {
    id
    polarity
    text
  }
  neutralAlerts: alerts(
    where: {
      polarity: {
        eq: 0
      }
    }
  ) {
    id
    polarity
    text
  }
  negativeAlerts: alerts(
    where: {
      polarity: {
        lt: 0
      }
    }
  ) {
    id
    polarity
    text
  }
}

In addition to gt, lt and eq, you may use other IntComparisonExpression operators as needed.

PreviousPayload ObjectNextRestrictions on Usage

Last updated 3 years ago

Was this helpful?