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
  • Request
  • Response

Was this helpful?

  1. Company Data API
  2. Getting started

Getting started with Ruby

Company Data API querying example with Ruby

Request

require 'net/http'
require 'json'

API_KEY = "<REPLACE_WITH_YOUR_KEY>"
API_ENDPOINT = "https://api.craft.co/v1/query"
GRAPHQL_QUERY = "query getCompany($domain: String!) { company(domain: $domain) { locations { city, country } } }"

request_headers= { "Content-Type": "application/json", "x-craft-api-key": API_KEY }
request_data = {
    "query": GRAPHQL_QUERY,
    "variables": { "domain": "meta.com" }
}

response = Net::HTTP.post(URI(API_ENDPOINT), request_data.to_json, request_headers)
puts response.body

Make sure to replace <REPLACE_WITH_YOUR_KEY> with your unique API key.

Response

The above command returns JSON structured like this:

{
  "data": {
    "company": {
      "locations": [
        {
          "city": "Tokyo",
          "country": "JP"
        },
        {
          "city": "Ottawa",
          "country": "CA"
        },
        {
          "city": "Jakarta",
          "country": "ID"
        },
       ... 
      ]
    }
  }
}

Read more

PreviousGetting started with PythonNextGetting started with cURL

Last updated 2 years ago

Was this helpful?

Query basic company info
Query financials
Query operating data
Query human capital data