Download Client¶
- class legislice.download.Client(api_token='', api_root='https://authorityspoke.com/api/v1', update_coverage_from_api=True)¶
Downloader for legislative text.
- citations_to(target)¶
Load an InboundReference object for each provision citing the target USLM provision URI.
- Parameters
target (
Union
[str
,Enactment
,CrossReference
]) – a string URI for the cited node, an Enactment at the cited node, or a CrossReference to the cited node- Return type
- Returns
a list of InboundReferences to the cited node
- fetch(query, date='')¶
Download legislative provision from string identifier or cross-reference.
- Parameters
query (
Union
[str
,CitingProvisionLocation
,CrossReference
,InboundReference
]) – A cross-reference to the desired legislative provision, or a path to the desired legislation section using the United States Legislation Markup tree-like citation format.date (
Union
[date
,str
]) – The date of the desired version of the provision to be downloaded. This is not needed if aCrossReference
passed to thequery
param specifies a date. If no date is provided, the API will use the most recent date.
- Return type
Dict
[str
,Union
[Any
,str
,List
[Union
[str
,Dict
[str
,str
]]]]]
- fetch_citations_to(target)¶
Query API for citations to a given target node, withoout loading them as InboundCitations.
- fetch_citing_provision(query)¶
Download legislative provision as Enactment from CitingProvisionLocation.
CitingProvisionLocations are found in the locations attribute of the InboundReference objects obtained when using the citations_to method.
- fetch_cross_reference(query, date='')¶
Download legislative provision from cross-reference.
- Parameters
query (
CrossReference
) – A cross-reference to the desired legislative provision. Found by calling thecross_references()
method on anEnactment
that contains one or more citations to other provisions.date (
Union
[date
,str
]) – The date of the desired version of the provision to be downloaded. This is not needed if theCrossReference
passed to thequery
param specifies a date. If no date is provided, the API will use the most recent date.
- Return type
Dict
[str
,Union
[Any
,str
,List
[Union
[str
,Dict
[str
,str
]]]]]
- fetch_db_coverage(code_uri)¶
Document date range of provisions of a code of laws available in API database.
- fetch_inbound_reference(query)¶
Download legislative provision from InboundReference.
- Parameters
query (
InboundReference
) – An InboundReference identifying a provision containing a citation.- Return type
Dict
[str
,Union
[Any
,str
,List
[Union
[str
,Dict
[str
,str
]]]]]- Returns
An Enactment representing the provision containing the citation (not the cited provision).
If the InboundReference has been enacted more than once, the latest one will be chosen.
- fetch_uri(query, date='')¶
Fetch data about legislation at specified path and date from Client’s assigned API root.
- Parameters
query (
str
) – A path to the desired legislation section using the United States Legislation Markup tree-like citation format. Examples: “/us/const/amendment/IV”, “/us/usc/t17/s103”date (
Union
[date
,str
]) – A date when the desired version of the legislation was in effect. This does not need to be the “effective date” or the first date when the version was in effect. However, if you select a date when two versions of the provision were in effect at the same time, you will be given the version that became effective later.
- Return type
Dict
[str
,Union
[Any
,str
,List
[Union
[str
,Dict
[str
,str
]]]]]
- get_db_coverage(uri)¶
Add data about the API’s coverage date range to the Enactment to be loaded.
As a side effect, changes the Client’s “coverage” attribute.
- read(query, date='')¶
Fetch data from Client’s assigned API root and builds Enactment or LinkedEnactment.
All text is selected by default.
- Parameters
path – A path to the desired legislation section using the United States Legislation Markup tree-like citation format. Examples: “/us/const/amendment/IV”, “/us/usc/t17/s103”
date (
Union
[date
,str
]) – A date when the desired version of the legislation was in effect. This does not need to be the “effective date” or the first date when the version was in effect. However, if you select a date when two versions of the provision were in effect at the same time, you will be given the version that became effective later.
- Return type
- read_from_json(data, use_text_expansion=True)¶
Create a new
Enactment
object using imported JSON data.If fields are missing from the JSON, they will be fetched using the API key.
- Return type
- read_passage_from_json(data)¶
Create a new
EnactmentPassage
object using imported JSON data.If fields are missing from the JSON, they will be fetched using the API key.
- Return type
- update_data_from_api_if_needed(data)¶
Update data from API with data from API coverage.
- update_enactment_from_api(data)¶
Use API to fill in missing fields in a dict representing an
Enactment
.Useful when the dict has missing data because it was created by a user.
- update_entries_in_enactment_index(enactment_index)¶
Fill in missing fields in every entry in an
EnactmentIndex
.