How to access and use Listly API
What is Listly API?
Listly API allows you to connect other external services with Listly to go beyond the integrations we provide, such as data visualization and workflow management solutions. Every single web scraping result page includes the API button, which enables you to connect to Google Sheets or your own database. Any request to Listly API must be accompanied by an API Token, so if it’s your first time using Listly API you may want to generate your API Token first.
How to get an API URL Path?
An API URL refers to an address that allows you to access an API. If you're setting it up for the first time, you'll see a prompt to generate an API token as shown in the second image. Please make sure to generate it in one click and double-check if the token was generated by clicking the API button.
Types of APIs
APIs are composed of two parts:
- Latest API: displays a table of the latest successfully-scraped data
- Log API: displays a table of all API processing logs
In the single or group extraction results page, you can use both latest and log APIs.
- Single latest data
- Single log data
- Group latest data
- Group log data
Single Latest & Single Log Data
- The latest data for single extraction can be found on the results page using Single Latest.
- Log data for single extraction can be found on the results page using Single Log.
Group Latest & Group Log Data
- Latest data for group extraction can be found using Group API.
- Log data for group extraction can be found by clicking on Logs and selecting the log data that you want to view. Then, click Group API.
What is an API endpoint?
An API Endpoint is a specific location where an API receives requests from an application and sends the information requested.
- Single (Latest): pulls the latest data. It is used when the extraction is repeated periodically using a scheduler.
- www.listly.io/api/single?key=<singlekey>
- GET
- Single (Log): pulls all data. It is used to fetch data and inspect the response at once.
- www.listly.io/api/single/data?key=<datakey>
- GET
- Group (Latest): pulls the latest group data.
- www.listly.io/api/group?key=<groupkey>
- GET
- Group (Log): pulls the selected data by batch group. The batch increases by one whenever the group data is newly extracted.
- www.listly.io/api/group/data?key=<datakey>
- GET
How many types of API parameters are there?
- Single (Latest) data API
www.listly.io/api/single?key=<singlekey>&selected=1&arrange=y&href=n&file=csv
- Single (Logs) data API
www.listly.io/api/single/data?key=<datakey>&selected=1&arrange=y&href=n&stack=vertical&file=csv
<datakey> is a key value of the page used for accessing public data. Based on the tab selected, it retrieves the latest or log data.
Name / data type / value / default
- selected: int / 1, 2, 3 ... / 1
- arrange: string / y, n / y
- href: string / y, n / n
- stack: string / vertical, horizontal / vertical
- file: string / csv, json / json
- from: datatime / 2020-11-01T00:00
- to: datatime / 2020-11-11T23:59
Code Examples
import requests
import csv
API_URL = "API URI" # Enter the 'API address' of the collected data
API_TOKEN = "API Token" # Enter the 'API Token' issued to your account
headers = { "Authorization": API_TOKEN }
# Load collected data
response = requests.get(url=API_URL, headers=headers)
content = response.content
# Save as CSV file
"""
If the format of the file called by the API address is JSON, not CSV
You must use a different code for that.
"""
with open('./result.csv', 'wb') as f:
f.write(content)
import requests
import csv
API_URL = "https://www.listly.io/api/single?key=CmKQ625S&selected=1&arrange=y&href=n&file=csv"
API_TOKEN = "BC1Sx370Yows25RxaBMuRxTuMKw3Aq0Ks"
headers = { "Authorization": API_TOKEN }
response = requests.get(url=API_URL, headers=headers)
content = response.content
with open('./result.csv', 'wb') as f:
f.write(content)