Releases: popmonkey/irdata
automatic rate limit and retry handling
See the README for some automatic error handling including recovery from rate limiting and temporary errors (such as during iRacing downtimes)
Full Changelog: v0.4.5...v0.5.0
handle case where chunk_info is present but nil
Turns out some iRacing data API endpoints can return a chunk_info
that's empty and doesn't actually point to any chunks. ignore these.
Full Changelog: v0.4.4...v0.4.5
New chunk handling behavior
Warning
This is a breaking for any APIs that emit chunked data
Some iRacing data APIs return chunked data at the top level, others inside the object. The previous code assumed only the former.
From now on, instead of replacing all the data returned by the API, whenever chunked results are detected (chunk_info
is present), irdata
resolves the chunks into a new parameter at the same level as the chunk_info
.
So for example, if the API returns something like:
{
"foo": "bar",
"chunk_info": { /* chunk info data */ }
}
irdata used to return
[
"chunk_data_1",
"chunk_data_2",
...
]
From now on, however, it will return:
{
"foo": "bar",
"chunk_info": { /* chunk info data */ }
"_chunk_data": [
"chunk_data_1",
"chunk_data_2",
...
]
}
Full Changelog: v0.4.3...v0.4.4
auth change: will now verify credentials before saving them
Warning
This is a potentially breaking change
SaveProvidedCredsToFile
is now AuthAndSaveProvidedCredsToFile
and it will authenticate before saving creds. This is to avoid a creds file that contains bogus credentials.
If you currently do something like:
api = irdata.Open(context)
irdata.SaveProvidedCredsToFile(keyFile, credsFile, credsProvider)
api.AuthWithCredsFromFile(keyFile, credsFile)
you'll need to do this instead:
api = irdata.Open(context)
api.AuthAndSaveProvidedCredsToFile(keyFile, credsFile, credsProvider)
other changes
example.key
has been removed to avoid everyone using the same keyirfetch
has a new option to just auth and exit (-a
) - useful for seeding a creds file
Full Changelog: v0.4.2...v0.4.3
support APIs that return a data_url
some APIs return an s3 data_url
instead of an s3 link
. follow those as well
more robust irfetch example
the fetch
example has been renamed to irfetch
and its functionality made more customizeable.
Here's the usage (./irfetch -h
):
irfetch is a tool to return results from any iRacing /data API endpoint.
It automatically follows s3Links as well as detecting and combining chunked results.
You will need to create a secret key to encrypt your credentials. See the
instructions here:
https://github.com/popmonkey/irdata#creating-and-protecting-the-keyfile
The first time irfetch is used it will request creds from the terminal. It will
then use the keyfile to encrypt these in the specified credsfile.
Note that the api request should be in the form of a URI, not a full URL.
irfetch creates a .irfetch_cache directory in the current working directory. This
directory is used to cache results from calls to iRacings /data API for
15 minutes (by default). Subsequent requests to the same URI will return
data from this cache until that it is expired.
(irfetch is built in Go using the irdata library at https://github.com/popmonkey/irdata)
Example:
irfetch ~/my.key -c -cachettl 60m ~/ir.creds /data/member/info
Usage: irfetch [options] <path to keyfile> <path to credsfile> <api uri>
-c cache api results
-cache
cache api results
-cachedir string
path to cache directory (default ".irfetch_cache")
-cachettl duration
cache TTL for this call (default 15m0s)
-h show help
-help
show help
-v log verbosely
error handling and logging changes
got rid of almost all the panics and modified interfaces to return error like a proper go module :)
also went through the logs and cleaned stuff up
opaque chunk support + logrus
chunk handling was awkward to use in v0.2.0. in the new version a normal json object is merged from all the chunks on the user's behalf.
v0.3.0 also introduces better logging via logrus
bugs fixed:
- cache closing will not panic if RunGC or Merge fail
Full Changelog: v0.2.0...v0.3.0
Note
this release includes the fetch
binary which can be used to get json
results from any of the APIs
chunk support
This release adds support for chunked responses from APIs like /data/results/search_series
Full Changelog: v0.1.0...v0.2.0