Forum Discussion

pmershon's avatar
pmershon
New Member
2 years ago
Solved

API request using FunctionIInvokeAfter - stop delays once all the data is loaded

Hello, I am working for a cheminformatics research lab and we are currently trying to automate some of our data entry. Eventually we will most likely move on to using R or SQL, but for right now we ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi pmershon ,
    Based on your description and the code provided, since each API call is very time-consuming, please minimize the number of calls by batching requests whenever possible. Although the CrossRef API does not support multiple queries in a single request, you can still optimize by reducing unnecessary steps in your queries.
    You can try creating a custom function

    let
        fxGetCrossRefDOI = (Title) =>
            let
                baseURL = "https://api.crossref.org/works",
                query = Uri.EscapeDataString(Title),
                URL = baseURL & "?rows=1&sort=relevance&query.bibliographic=" & query & "&select=title,container-title,DOI,ISSN&filter=type:journal-article",
                response = Json.Document(Web.Contents(URL))
            in
                response
    in
        fxGetCrossRefDOI
    

    Of course, you can also use Table.Buffer, which helps to minimize the number of times you have to read data from the source. You can use load data into memory, which may speed up subsequent steps
    Table.Buffer - PowerQuery M | Microsoft Learn
    You can also refer to this document to learn how to use the Rest API
    TripPin 2 - REST - Power Query | Microsoft Learn

    Best regards,
    Albert He

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly