Instructions on API-Based Data Fetching

  • Last update: February 12, 2025
  • Overview

    FineDataLink provides two functions to fetch data from APIs, with the following differences: 

    FunctionDescription
    The API Input function in Data SynchronizationIf the API returns JSON data that requires no complex parsing, you can refer to this article to fetch data from it.
    The API Input operator in Data TransformationThe API Input function in Data Synchronization does not support further processing of the data fetched from the API. To achieve that, you should use the API Input operator to fetch data and use other operators for further processing. 

    This document describes how to use the two functions in practical scenarios.

    iconNote:
    The value of the parameter output by the Parameter Assignment node or the Parameter Output operator with enabled Closure Character is enclosed with single quotation marks by default. If you enclose the parameter with single or double quotation marks to reference it during API-based data fetching, data fetching may fail. Therefore, enable Closure Character according to actual conditions.

    Simple API-Based Data Fetching

    Fetching Data from the API and Saving It

    Scenario Description

    The data fetched from the API requires simple parsing.

    Implementation Method

    1721267012461516_fixed.jpeg

    Method One:

    Use the API Input function in Data Synchronization to get the required dataas shown in the following figure.

    Method Two:

    Use the API Input operator to read data from the API, then parse data using the JSON Parsing or the XML Parsing operator,  and finally, output the data. (You can use other data processing operators to further process the data before outputting it.)

    Example

    For details, see Data Synchronization - APIXML Parsing, Executing the Scheduled Task on Weekdays Onlyand Calling Scheduled Task Related APIs.

    Fetching Data from the API and Outputting it as a Parameter

    Application Scenario

    Read data from the API and output it as a parameter for it to be used by subsequent nodes/operators.

    Implementation Method

    You can output the data fetched from the API as a parameter using the Parameter Assignment nodes, the Parameter Output operator, and the Assignment Parameter function in Global Parameter, where the API response headers, response body, and status code can be obtained.

    For details, see API Input.

    1721268402736914_fixed (1).jpeg

    Example

    You want to call an API named Get_Department_List to obtain all department IDs. Calling Get_Department_List requires using the access_token parameter, which can be obtained by calling another API named Get_Access_Token.

    Therefore, you need to call Get_Access_Token to obtain the access token and output it as a parameter, and use the parameter to call Get_Department_List.

    Paginated Data Fetch

    Scenario Description

    You can use the paginated data fetching scheme when the API contains pagination-related parameters (such as pageIndexpageSize, and pagination parameters). 

    Implementation Method

    iconNote:
    If a page contains no data, the data fetched from it is empty during paginated data fetching, which may cause a task execution error.

    Method One:

    FineDataLink provides a Paginated Data Fetch function. For details, see API Input - Paginated Data Fetching.

    Method Two:

    Using API Input in combination with the Loop Container node. You are advised to learn how to use Loop Container and then study documents introducing paginated data fetching.

    Example

    For details, see Overview of API-Based Data Fetching.

    For details about fetching data from an API using both Loop Container and pagination methods, see Fetching Data Using a Nested Loop.

    Looping Through API Data Without Pagination

    Application Scenario

    You need to fetch data from an API that accepts only a single value for a given parameter at one time. To facilitate data fetching from the API, you can obtain the parameter values used to call the API, output them to a new parameter, and use the Loop Container node to traverse all parameter values.

    iconNote:
    Set Loop Type to For-Each Loop or Do-While Loop according to the actual scenario. For details, see Description of Loop Container Logic.

    Implementation Method

    Use the API input and the parameter functions in combination with the Loop Container node. The following is an example.

    You want to call the Get_Department_Member API to obtain the user IDs, which requires using the parameters Access_Token and Department_ID. The Get_Department_Member API accepts only a single value for a parameter at a time. To facilitate data fetching, you can:

    1. Call the Get_Access_Token API to obtain the access token and output it to the Access_Token parameter. (The parameter value is dynamic.)

    2. Call the Get_Department_List API to obtain all department IDs and output them to the Department_ID parameter.

    3. Use the Access_Token and Department_ID parameters in a Loop Container node for it to iterate through all access tokens and department IDs to fetch data.

    1721201439976678_fixed.jpeg

    Encrypted Data Fetching

    Application Scenario

    You want to encrypt the API calls with encrypted parameters. For example, calling the Get_Ticket_List API requires using the signature parameter sign, and the request is accepted only when the sign value is valid.

    Implementation Method

    Use the encryption function to encrypt the parameter in the Spark SQL operator. For details, see Encryption Function.

    附件列表


    主题: Data Development - Scheduled Task
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    9s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy