Cross platform API for fetching public data from canada.ca.
<script src="https://cdn.jsdelivr.net/npm/canada-api@4.0.0"></script>
npm install canada-api
const ca = require('canada-api')
-
url
{string|URL} relative or absolute URL on canada.ca - Returns: {Promise} Fulfills with axios response {Object} upon success
Throws {Error} if the request does not complete successfully or if the destination URL is not on canada.ca.
{
"data": {},
"status": 200,
"statusText": "OK",
"headers": {},
"config": {},
"request": {}
}
-
url
{string|URL} node URL
Validates and formats canada.ca. Throws an {Error} if the URL is invalid, or the type requested is not possible.
-
url
{string|URL} absolute or relative URL - Returns: {Promise} Fulfills with {Object} containing child nodes
Parses sitemaps to get a list of child nodes.
{
"data": [
{
"path": "https://www.canada.ca/en/department-national-defence/...",
"lastmod": "2022-09-20"
},
]
}
Getting children of DAM folders/assets is not available.
-
url
{string|URL} absolute or relative URL - Returns: {Promise} Fulfills with {Object} containing document contents
Retrieves the document contents.
{
"data": "<!DOCTYPE html>\r\n...."
}
-
url
{string|URL} absolute or relative URL - Returns: {Promise} Fulfills with {Object} containing metadata properties
Nodes contain a variety of metadata properties that can be accessed through a public API. Some properties such as date formats are reformatted for consistency.
{
"data": {
"cq:lastModified": "2022-10-25T19:16:28.000Z",
"fluidWidth": false,
}
}