[Python] AISWEI Solar API - Get Plant List

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect with the AISWEI Solar API. I was sent a API user manual and a Token by email. When i log into my account online I also see an APP Key which consists of a 9 digit number and a alphanumeric string after that. My issue is that i have tried various HTTP request from python and ARC clients. I still seem to get no response back from their servers. I am trying to use the getPlantList conmmand.

    [​IMG]

    Going by the API document, i first thought the request URL was a typo but if I type is as is, I get a 400 - bad request instead of a 404 - not found. So I assume the URL is correct.

    Has anyone used this API or can assist me in fixing my code?

    Below is my python code:

    import requests

    def get_plant_list(token, page=1, size=20):
    url = 'https://api.general.aisweicloud.com/planlist'
    params = {
    'token': token,
    'page': str(page),
    'size': str(size)
    }

    try:
    response = requests.get(url, params=params, verify=False)

    if response.status_code == 200:
    return response.json()
    else:
    print(f"Request failed with status code: {response.status_code}")
    return None

    except requests.exceptions.RequestException as e:
    print("An error occurred while making the request:", e)
    return None

    token = 'XXXXXXXXXXXXX'

    plant_list = get_plant_list(token)

    if plant_list:
    print(plant_list)


    Also I have share the API Manual here:

    API Manual

    Sorry I don't know how to upload PDFs here.

    Continue reading...

Compartilhe esta Página