Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Response Time Issue with Scrip Master Contract Download #294

Open
marketcalls opened this issue May 21, 2024 · 1 comment
Open

Server Response Time Issue with Scrip Master Contract Download #294

marketcalls opened this issue May 21, 2024 · 1 comment

Comments

@marketcalls
Copy link

  • 5paisa Python SDK version: Used API
  • Python version: 3.11.7
  • Operating System: Windows OS

Description

I am experiencing a significant delay in server response time when downloading the Master contract CSV file from the 5Paisa API. Below is the Python code I am using to measure the response time and download the file:

What I Did

Python Code Used to Measure the Response Time

import requests
import time
from tqdm import tqdm

# URL of the CSV file
url = "https://openapi.5paisa.com/VendorsAPI/Service1.svc/ScripMaster/segment/all"

# Measure time taken to get server response
start_time = time.time()
response = requests.get(url, stream=True)
response_time = time.time() - start_time

print(f"Time taken for server to respond: {response_time:.2f} seconds")

# Check if the request was successful
if response.status_code == 200:
    # Get the total file size
    total_size = int(response.headers.get('content-length', 0))
    block_size = 1024  # 1 Kilobyte
    t = tqdm(total=total_size, unit='iB', unit_scale=True)

    download_start_time = time.time()
    with open('scrip_master.csv', 'wb') as file:
        for data in response.iter_content(block_size):
            t.update(len(data))
            file.write(data)
    t.close()
    download_time = time.time() - download_start_time

    if total_size != 0 and t.n != total_size:
        print("Error occurred during download.")
    else:
        print(f"CSV file downloaded successfully.")
        print(f"Time taken to download the file: {download_time:.2f} seconds")
else:
    print(f"Failed to download CSV file. Status code: {response.status_code}")

Output

Time taken for server to respond: 47.92 seconds
28.0MiB [00:02, 10.5MiB/s]
CSV file downloaded successfully.
Time taken to download the file: 2.66 seconds

Issue:

The response time from the server is approximately 47.92 seconds, which is considerably high. However, once the response is received, the download speed is acceptable, taking around 2.66 seconds to download the 28.0 MiB file.

Request:

Could you please look into this issue and help improve the server response time for downloading the Master contract CSV file? This delay significantly affects the performance of our applications relying on your API.

@knkrth
Copy link

knkrth commented Jun 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants