Giter Site home page Giter Site logo

jackiebinbin / api-data-fetcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hosir-web3/api-data-fetcher

0.0 0.0 0.0 3 KB

A Python script to fetch and handle data from an API with error handling and retry mechanism.

License: MIT License

Python 100.00%

api-data-fetcher's Introduction

API Data Fetcher

This Python script fetches data from the specified API URL and prints the JSON data to the console. It handles common errors, such as 502 Bad Gateway, 504 Gateway Timeout, and ConnectionError, by retrying the request with a delay.

Requirements

  • Python 3.6 or higher
  • requests library

Installation

  1. Clone this repository or download the script.
  2. Install the required library using pip: pip install requests

Usage

  1. Open the api_data_fetcher.py script in a text editor.
  2. Modify the base_url and address variables to match the desired API endpoint and address.
  3. Save the script and run it using the command: python api_data_fetcher.py

The script will fetch the data from the API and print it to the console. If an error is encountered, the script will retry the request up to the specified maximum number of retries.

Configuration

You can adjust the max_retries and retry_delay parameters in the fetch_data function to control the behavior of the retry mechanism.

api-data-fetcher's People

Contributors

hosir-web3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.