GraphQL Extractor avatar

GraphQL Extractor

Try for free

No credit card required

View all Actors
GraphQL Extractor

GraphQL Extractor

jupri/graphql-extractor
Try for free

No credit card required

💫 Universal GraphQL Scraper

You can access the GraphQL Extractor programmatically from your own JavaScript applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4// Replace the '<YOUR_API_TOKEN>' with your token
5const client = new ApifyClient({
6    token: '<YOUR_API_TOKEN>',
7});
8
9// Prepare Actor input
10const input = {
11    "limit": 100,
12    "url": "https://apify.hashnode.dev/api/graphql",
13    "query": `query ($host: String!, $after: String, $first: Int!, $filter: PublicationPostConnectionFilter) {
14            publication(host: $host) {
15                id
16                posts(after: $after, first: $first, filter: $filter) {
17                    edges {
18                        node {
19                            __typename id title subtitle slug publishedAt url brief
20                        }
21                        __typename
22                    }
23                    pageInfo { hasNextPage endCursor __typename }
24                    totalDocuments
25                    __typename
26                }
27                __typename
28            }
29        }`,
30    "variables": "{ \"host\": \"apify.hashnode.dev\", \"first\": 10 }",
31    "cursor.step": 25,
32    "cursor.index": "",
33    "cursor.next": "after",
34    "cursor.offset": "",
35    "cursor.limit": "first",
36    "parse.root": "publication.posts",
37    "parse.list": "edges",
38    "parse.item": "node",
39    "parse.total": "totalDocuments",
40    "parse.next": "pageInfo.endCursor"
41};
42
43// Run the Actor and wait for it to finish
44const run = await client.actor("jupri/graphql-extractor").call(input);
45
46// Fetch and print Actor results from the run's dataset (if any)
47console.log('Results from dataset');
48console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
49const { items } = await client.dataset(run.defaultDatasetId).listItems();
50items.forEach((item) => {
51    console.dir(item);
52});
53
54// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

GraphQL Extractor API in JavaScript

The Apify API client for JavaScript is the official library that allows you to use GraphQL Extractor API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.

Install the apify-client

npm install apify-client

Other API clients include:

Developer
Maintained by Community
Actor metrics
  • 3 monthly users
  • 1 star
  • 78.8% runs succeeded
  • Created in Oct 2024
  • Modified 11 days ago
Categories