Companies are allowed to create their own concepts. The conccept AccruedAndOtherCurrentLiabilities
is generated by tesla
. Get all us-gaap concepts from ssec's RESTful api with python code:
import requests
import json
cik='1318605' #tesla's cik
url = 'https://data.sec.gov/api/xbrl/companyfacts/CIK{:>010s}.json'.format(cik)
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
}
res = requests.get(url=url,headers=headers)
result = json.loads(res.text)
us_gaap_concepts = list(result['facts']['us-gaap'].keys())
Revenues
is a us-gaap concept,verify it with code.
'Revenues' in us_gaap_concepts
True
Verify that AccruedAndOtherCurrentLiabilities
is not in us_gaap_concepts.
'AccruedAndOtherCurrentLiabilities' in us_gaap_concepts
False
How can get all company customized concepts from sec's data api or some file then?
If I understand you correctly, one way to get the company's US GAAP taxonomy concept extensions (there may be others) is to do the following. Note that the data is in xml format, not json, so you will need to use an xml parser.
If you look at the company's 10-K filing for 2020, for example, you will notice that, at the bottom, there is a list of data files, the first one described as "XBRL TAXONOMY EXTENSION SCHEMA" and named "tsla-20201231.xsd". That's the file you're looking for. Copy the url and get started. BTW, it's probably possible to automate all this, but that's a different topic.
from lxml import etree
import requests
#get the file
url = 'https://www.sec.gov/Archives/edgar/data/1318605/000156459021004599/tsla-20201231.xsd'
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
}
req = requests.get(url,headers=headers)
#load it into lxml for parsing
doc = etree.XML(req.content)
#search for the customized concepts
tsla_concepts = doc.xpath('//*[@id[starts-with(.,"tsla_")]]/@name')
tsla_concepts
You get a list of 328 customized concepts. Your AccruedAndOtherCurrentLiabilities
is somewhere near the top:
['FiniteLivedIntangibleAssetsLiabilitiesOther',
'IndefiniteLivedIntangibleAssetsGrossExcludingGoodwill',
'IndefiniteLivedIntangibleAssetsOtherAdjustments',
etc.