{"id":20940882,"url":"https://github.com/timhanewich/xbrl","last_synced_at":"2025-06-13T07:04:32.187Z","repository":{"id":40868849,"uuid":"261356223","full_name":"TimHanewich/Xbrl","owner":"TimHanewich","description":"XBRL Document Reading Library.  Code behind the NuGet package available at https://www.nuget.org/packages/Xbrl/","archived":false,"fork":false,"pushed_at":"2022-12-08T10:41:54.000Z","size":732,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T20:56:35.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/Xbrl/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimHanewich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-05T03:50:30.000Z","updated_at":"2025-05-09T23:07:24.000Z","dependencies_parsed_at":"2023-01-25T20:00:19.789Z","dependency_job_id":null,"html_url":"https://github.com/TimHanewich/Xbrl","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/TimHanewich/Xbrl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FXbrl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FXbrl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FXbrl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FXbrl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimHanewich","download_url":"https://codeload.github.com/TimHanewich/Xbrl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FXbrl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259599319,"owners_count":22882352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T23:12:16.824Z","updated_at":"2025-06-13T07:04:32.127Z","avatar_url":"https://github.com/TimHanewich.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Import the Xbrl namespace and components by placing the following code at the top of your code document:\n~~~\nusing Xbrl;\n~~~\n\n### Opening an XBRL Instance Document\nAn Xbrl document can be opened through a byte Stream.  This stream can be sourced from a locally saved file or through the \"SecuritiesExchangeCommission.Edgar\" NuGet solution package.  I've used the named NuGet package here:\n~~~\n//Search for a 10-K XBRL document and then download to a Stream\nEdgarSearch es = await EdgarSearch.CreateAsync(\"INTC\", \"10-K\");\nEdgarSearchResult esr = es.GetFirstResultOfFilingType(\"10-K\");\nStream s = await esr.DownloadXbrlDocumentAsync();\n\n//Read the XBRL document\nXbrlInstanceDocument doc = XbrlInstanceDocument.Create(s);\n~~~\n\n### Listing all facts\n~~~\n//List all facts\nforeach (XbrlFact fact in doc.Facts)\n{\n\tConsole.WriteLine(fact.Label + \": \" + fact.Value.ToString(\"#,##0.00\");\n}\n~~~\n\n### Listing all Context References\nEach Context Reference contains five properties:\n\n`Id` - The ID of the Context Ref. This is used by Facts to reference their time period.  \n`TimeType` - Specifies the time type for this context reference (either a period with a start or end date, or a \"snapshop\" on a specific day)  \n`InstantDate` - If the time type is instant (\"snapshot\"), this marks the date of the snapshot.  \n`StartDate` - If the time type is period (a period of time), this marks the period begin date.  \n`EndDate` - If the time type is period (a period of time), this marks the period end date.\n\nExample of listing all properties of each context reference in an Instance Document:\n~~~\n//List all context references\nforeach (XbrlContext context in doc.Contexts)\n{\n    Console.WriteLine(\"ID: \" + context.Id);\n    Console.WriteLine(\"Time Type: \" + context.TimeType.ToString());\n    if (context.TimeType == XbrlTimeType.Instant)\n    {\n        Console.WriteLine(\"Instant Date: \" + context.InstantDate.ToShortDateString());\n    }\n    else if (context.TimeType == XbrlTimeType.Period)\n    {\n        Console.WriteLine(\"Start Date: \" + context.StartDate.ToShortDateString());\n        Console.WriteLine(\"End Date: \" + context.EndDate.ToShortDateString());\n    }\n}\n~~~\n\n### Referencing a Fact's Context Reference\nThe `XbrlInstanceDocument` class provides the `GetContextById` method to search through the array of Context References and return the match.  \nYou can pass the `ContextId` string to this method to return the `XbrlContext` object.\nFor example:\n~~~\n//Get a fact's Context Reference\nXbrlContext context = doc.GetContextById(doc.Facts[0].ContextId);\n~~~\n\n### Using the XBRL Helper\nMany companies will include multiple facts of the same type in their document, each for a different fiscal period. For example, including the annual revenue of 2014, 2015, and 2016, all with them same label name. This package also provides a helper class to assist with extracting of *current* facts, related directly to this period.  \nImport the helper class by placing this at the top of your code file:\n~~~\nusing Xbrl.Helpers;\n~~~\nThis will add an extension method to an `XbrlInstanceDocument` object called `GetValueFromPriorities`. This method will look for facts that are only relevent to the documents current time period. You can provide multiple labels to search for and the method will search for a fact with the first label, move onto the next if it was unable to find one, and so forth.  \nFor example, if a company either labeled their Current Assets from their balance sheet as \"AssetsCurrent\" or \"CurrentAssets\", we would use the following code to return this fact.\n~~~\nXbrlFact current_assets = doc.GetValueFromPriorities(\"CurrentAssets\", \"AssetsCurrent\");\n~~~\n\n### Converting an Instance Document to a Common Financial Statement\nCompanies use different terms and keywords to refer to common items on their financial statements. The XBRL package also provides a way to convert an XBRL Instance Document into a \"common\" financial statement with data that is commonly found in every set of financial statemnets like Revenue, Net Income, Assets, Equity, etc.  \nPlace this line at the top of you code file:\n~~~\nusing Xbrl.FinancialStatement;\n~~~\nImporting the namespace with the code below adds an extension method to the `XbrlInstanceDocument` class. Below is an example of converting an `XbrlInstanceDocument` into a Financial Statement.\n~~~\nFinancialStatement fs = doc.CreateFinancialStatement();\n~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fxbrl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimhanewich%2Fxbrl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fxbrl/lists"}