idloc


Nameidloc JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryFind and get readable JSON-LD from Library of Congress Linked Data Service
upload_time2025-07-11 22:05:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseThe MIT License (MIT) Copyright (c) Ed Summers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # idloc 

[![Build Status](https://github.com/edsu/idloc/actions/workflows/test.yml/badge.svg)](https://github.com/edsu/idloc/actions/workflows/test.yml)


*idloc* is a command line utility and small function library for getting JSON-LD from the Library of Congress Linked Data service at https://id.loc.gov.

Ideally *idloc* would not be needed at all because you could just use [curl](https://curl.se/) or whatever HTTP library you want to fetch the JSON-LD directly. But at the moment the JSON-LD that is returned, while valid, isn't exactly usable and needs to be [framed](https://www.w3.org/TR/json-ld11-framing/). *idloc* uses [pyld] internally to do the framing that makes the JSON usable by someone who just wants to use the data as JSON without the cognitive overhead of using RDF processing tools.

## Install

This will install *idloc* and its dependencies:

```bash
pip install idloc
```

## CLI

Once installed you should also have a *idloc* command line utility available. There are four commands get, lucky, search, concept-schemes.

### Get

Get will fetch the id.loc.gov entity by URI and print out the framed JSON-LD:

```bash
$ idloc get https://id.loc.gov/authorities/subjects/sh2002000569
```

To see the output of this command see [this file](https://raw.githubusercontent.com/edsu/idloc/refs/heads/main/examples/sh2002000569.json) since it's really too long to include inline here in the docs.

Compare that to the JSON that is being made available at https://id.loc.gov/authorities/subjects/sh85021262.json and you will probably see why *framing* the JSON-LD is currently needed if you want to work with the data as JSON.

### Lucky

If you want to roll the dice and see the JSON-LD for first entity that matches a given string:

```
$ idloc lucky "Semantic Web"
```

If you want to limit to particular concept schemes like `subject-headings` you can:

```
$idloc lucky --concept-scheme subject-headings "Semantic Web"
```

### Search

You can search for entities:

```
$ idloc search "Semantic Web" --limit 5

International Semantic Web Conference (6th : 2007 : Pusan, Korea) Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings
<http://id.loc.gov/resources/works/15024802>

International Semantic Web Conference (6th : 2007 : Pusan, Korea) The Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings Berlin ; New York : Springer, 2007.
<http://id.loc.gov/resources/instances/15024802>

IFIP WG 12.5 Working Conference on Industrial Applications of Semantic Web (1st : 2005 : Jyväskylä, Finland) Industrial applications of semantic Web : proceedings of the 1st IFIP WG12.5 Working Conference on Industrial Applications of Semantic Web, August 25-27, 2005, Jyväskylä, Finland New York : Springer, c2005.
<http://id.loc.gov/resources/instances/14054943>

International Semantic Web Conference (1st : 2002 : Sardinia, Italy) semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings
<http://id.loc.gov/resources/works/12761651>

International Semantic Web Conference (1st : 2002 : Sardinia, Italy) The semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings Berlin ; New York : Springer, c2002.
<http://id.loc.gov/resources/instances/12761651>
```

Notice how the top 5 were taken up with bibframe instances? Similar to `get` you can limit a search to one or more concept schemes. For example if we want to search for "Semantic Web" only in the `subject-headings` and `name-authority` concept schemes:

```
$ idloc search --concept-scheme subject-headings --concept-scheme name-authority "Semantic Web" 
```

### Concept Schemes

You may be wondering what concept schemes are available. To see a list of them:

```
$ idloc concept-schemes
```

## Use as a Library

The idloc Python library can be used in your Python programs.


### Get

You can get the JSON-LD for a given id.loc.gov URI:

```
import idloc

concept = idloc.get('http://id.loc.gov/authorities/subjects/sh2002000569')
```

### Search

You can search for entities:

```python
for result in idloc.search('Semantic Web'):
    print(result['title'], result['uri']
```

Similarly you can limit to particular concept schemes:

```python
for result in idloc.search('Semantic Web', concept_schemes=['subject-headings', 'name-authority']):
    print(result['title'], result['uri'])
```

By default you get the first 20 results, but you can use the `limit` parameter to get more. If you set `limit` to `0` it will page through all the results.

### Concept Schemes

A mapping of concept scheme names and their corresponding URIs is available in:

```python
idloc.CONCEPT_SCHEMES
```

There are 130 of them! There is also a function `idloc.concept_schemes()` which will scrape the search interface at https://id.loc.gov/search to determine what the latest group of concept schemes is.

[pyld]: https://github.com/digitalbazaar/pyld

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "idloc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/7b/a4/47d35535a4f2c5e6b1257b9dcdb6f2448fd9ad382623247c8446c6367064/idloc-0.2.0.tar.gz",
    "platform": null,
    "description": "# idloc \n\n[![Build Status](https://github.com/edsu/idloc/actions/workflows/test.yml/badge.svg)](https://github.com/edsu/idloc/actions/workflows/test.yml)\n\n\n*idloc* is a command line utility and small function library for getting JSON-LD from the Library of Congress Linked Data service at https://id.loc.gov.\n\nIdeally *idloc* would not be needed at all because you could just use [curl](https://curl.se/) or whatever HTTP library you want to fetch the JSON-LD directly. But at the moment the JSON-LD that is returned, while valid, isn't exactly usable and needs to be [framed](https://www.w3.org/TR/json-ld11-framing/). *idloc* uses [pyld] internally to do the framing that makes the JSON usable by someone who just wants to use the data as JSON without the cognitive overhead of using RDF processing tools.\n\n## Install\n\nThis will install *idloc* and its dependencies:\n\n```bash\npip install idloc\n```\n\n## CLI\n\nOnce installed you should also have a *idloc* command line utility available. There are four commands get, lucky, search, concept-schemes.\n\n### Get\n\nGet will fetch the id.loc.gov entity by URI and print out the framed JSON-LD:\n\n```bash\n$ idloc get https://id.loc.gov/authorities/subjects/sh2002000569\n```\n\nTo see the output of this command see [this file](https://raw.githubusercontent.com/edsu/idloc/refs/heads/main/examples/sh2002000569.json) since it's really too long to include inline here in the docs.\n\nCompare that to the JSON that is being made available at https://id.loc.gov/authorities/subjects/sh85021262.json and you will probably see why *framing* the JSON-LD is currently needed if you want to work with the data as JSON.\n\n### Lucky\n\nIf you want to roll the dice and see the JSON-LD for first entity that matches a given string:\n\n```\n$ idloc lucky \"Semantic Web\"\n```\n\nIf you want to limit to particular concept schemes like `subject-headings` you can:\n\n```\n$idloc lucky --concept-scheme subject-headings \"Semantic Web\"\n```\n\n### Search\n\nYou can search for entities:\n\n```\n$ idloc search \"Semantic Web\" --limit 5\n\nInternational Semantic Web Conference (6th : 2007 : Pusan, Korea) Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings\n<http://id.loc.gov/resources/works/15024802>\n\nInternational Semantic Web Conference (6th : 2007 : Pusan, Korea) The Semantic Web : 6th International Semantic Web Conference, 2nd Asian Semantic Web Conference, ISWC 2007 + ASWC 2007, Busan, Korea, November 11-15, 2007 : proceedings Berlin ; New York : Springer, 2007.\n<http://id.loc.gov/resources/instances/15024802>\n\nIFIP WG 12.5 Working Conference on Industrial Applications of Semantic Web (1st : 2005 : Jyv\u00e4skyl\u00e4, Finland) Industrial applications of semantic Web : proceedings of the 1st IFIP WG12.5 Working Conference on Industrial Applications of Semantic Web, August 25-27, 2005, Jyv\u00e4skyl\u00e4, Finland New York : Springer, c2005.\n<http://id.loc.gov/resources/instances/14054943>\n\nInternational Semantic Web Conference (1st : 2002 : Sardinia, Italy) semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings\n<http://id.loc.gov/resources/works/12761651>\n\nInternational Semantic Web Conference (1st : 2002 : Sardinia, Italy) The semantic Web-ISWC 2002 : First International Semantic Web Conference, Sardinia, Italy, June 9-12, 2002 : proceedings Berlin ; New York : Springer, c2002.\n<http://id.loc.gov/resources/instances/12761651>\n```\n\nNotice how the top 5 were taken up with bibframe instances? Similar to `get` you can limit a search to one or more concept schemes. For example if we want to search for \"Semantic Web\" only in the `subject-headings` and `name-authority` concept schemes:\n\n```\n$ idloc search --concept-scheme subject-headings --concept-scheme name-authority \"Semantic Web\" \n```\n\n### Concept Schemes\n\nYou may be wondering what concept schemes are available. To see a list of them:\n\n```\n$ idloc concept-schemes\n```\n\n## Use as a Library\n\nThe idloc Python library can be used in your Python programs.\n\n\n### Get\n\nYou can get the JSON-LD for a given id.loc.gov URI:\n\n```\nimport idloc\n\nconcept = idloc.get('http://id.loc.gov/authorities/subjects/sh2002000569')\n```\n\n### Search\n\nYou can search for entities:\n\n```python\nfor result in idloc.search('Semantic Web'):\n    print(result['title'], result['uri']\n```\n\nSimilarly you can limit to particular concept schemes:\n\n```python\nfor result in idloc.search('Semantic Web', concept_schemes=['subject-headings', 'name-authority']):\n    print(result['title'], result['uri'])\n```\n\nBy default you get the first 20 results, but you can use the `limit` parameter to get more. If you set `limit` to `0` it will page through all the results.\n\n### Concept Schemes\n\nA mapping of concept scheme names and their corresponding URIs is available in:\n\n```python\nidloc.CONCEPT_SCHEMES\n```\n\nThere are 130 of them! There is also a function `idloc.concept_schemes()` which will scrape the search interface at https://id.loc.gov/search to determine what the latest group of concept schemes is.\n\n[pyld]: https://github.com/digitalbazaar/pyld\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) Ed Summers  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Find and get readable JSON-LD from Library of Congress Linked Data Service",
    "version": "0.2.0",
    "project_urls": {
        "homepage": "https://github.com/edsu/idloc"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e8029522c1a239c9588b7d8179304baafb557db55c747c900a1ecca4e7fbd32a",
                "md5": "e679cc2da0256e93d2a0faa9a9975be5",
                "sha256": "422c13e42610584d6a1021594a35466deb4357d3049115d0c263b0b487586738"
            },
            "downloads": -1,
            "filename": "idloc-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e679cc2da0256e93d2a0faa9a9975be5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 9019,
            "upload_time": "2025-07-11T22:05:12",
            "upload_time_iso_8601": "2025-07-11T22:05:12.727661Z",
            "url": "https://files.pythonhosted.org/packages/e8/02/9522c1a239c9588b7d8179304baafb557db55c747c900a1ecca4e7fbd32a/idloc-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7ba447d35535a4f2c5e6b1257b9dcdb6f2448fd9ad382623247c8446c6367064",
                "md5": "e86a00479328228361a7f403e7e14923",
                "sha256": "fea7b9b00f2c87ab7ce6fcccdee32d61d0e93679cf9ac489976b26f5afcf794f"
            },
            "downloads": -1,
            "filename": "idloc-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e86a00479328228361a7f403e7e14923",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 8135,
            "upload_time": "2025-07-11T22:05:13",
            "upload_time_iso_8601": "2025-07-11T22:05:13.734318Z",
            "url": "https://files.pythonhosted.org/packages/7b/a4/47d35535a4f2c5e6b1257b9dcdb6f2448fd9ad382623247c8446c6367064/idloc-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-11 22:05:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "edsu",
    "github_project": "idloc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "idloc"
}
        
Elapsed time: 1.92382s