This is a simplified implementation. It shows how to read from the API. How you store the records, handle errors and run the loop in your own system is up to you.
How the script reads the feed
- It reads a page.
afteris thefeed_sequenceof the last record in the copy, or 0 when the copy is empty. - It reads the response line by line and stores each line in the same transaction. The response is JSON Lines: each line is one allocation record.
- When a response is empty, the copy has every record that Engrate stored. The script waits and reads again.
The script
copy_allocations.py
Next steps
- Allocation feed record gives the fields of each record.
- A timestep can have more than one value. See Multiple values per timestep for how to find the current one.