Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:33:56+00:00 2026-06-18T03:33:56+00:00

I have about 140,000 one time API calls I need to do, the problem

  • 0

I have about 140,000 one time API calls I need to do, the problem is that they all take about 15 seconds. This would take about 25 days to do successively, however, I’d like to get it done faster.

I’m planning on dumping the data returned into a MySQL database using a JSON parser and a function that takes the parsed data. I am familiar with Python and PHP.

What is the best way (as in, fastest and simplest to implement) to do a number of API calls concurrently and have the returned items parsed into a DB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:33:57+00:00Added an answer on June 18, 2026 at 3:33 am

    Probably you’ll have to try multithreading / multiprocessing.

    This will only help if multiple parallel calls are allowed by the API (and if the machine where the API is run is fast enough to process more than one call at a time).

    If the bottleneck is not your own CPU, you can simply use the threading module, as multiprocessing won’t have any more improvements.

    As unchecked code, you could try:

    import Queue
    import threading
    
    number_of_API_readers = 10
    
    parameters_queue = Queue.Queue()
    results_queue = Queue.Queue(100)
    
    for par in list_of_parameters:
        parameters_queue.put(par)
    
    def read_from_queue_and_write_to_db():
        while True:
            try:
                result = results_queue.get(timeout=30)
                #write result to DB
            except Queue.Full:
                break
    
    def query_API_and_write_to_queue():
        while True:
            try:
                par = parameters_queue.get(timeout=5)
                result = SomeAPI.call(par)
                results_queue.put(result)
            except Queue.Empty:
                break
    
    db_writer = threading.Thread(target=read_from_queue_and_write_to_db)
    api_readers = [threading.Thread(target=query_API_and_write_to_queue) 
                    for i in range(number_of_API_readers)]
    
    db_writer.start()
    for ar in api_readers:
        ar.start()
    

    The main ideas in this code:

    • have one thread writing to the database
    • have many, e.g., 10 threads querying the API
    • use (thread-safe) queues to synchronize the threads.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have about 8 entities that all have a one to one relationship with
i have about 140 - 150 stored procedures that I need to migrate from
I have about 20 grid views that I have to create. All of them
I have a TStatusBar that contains two status panels. The first one is about
How can I fetch large resultset in java? I have about 140,000 rows with
i have about 20 possible exception messages that i want thrown when an error
I have about 1500 images within a folder named 3410001ne => 3809962sw. I need
I have about 10 drop down list controls that get populated. Instead of copying/pasting
I have some working Javascript that manipulates the some DOM elements. The problem is,
I have all the necessary MFC libraries, they are all in a directory called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.