{"id":16452606,"url":"https://github.com/agent-hellboy/trace-dkey","last_synced_at":"2025-03-23T10:31:49.853Z","repository":{"id":61721110,"uuid":"554374999","full_name":"Agent-Hellboy/trace-dkey","owner":"Agent-Hellboy","description":"Python library to trace path of a particular key inside a nested dict","archived":false,"fork":false,"pushed_at":"2023-11-17T11:58:46.000Z","size":166,"stargazers_count":7,"open_issues_count":5,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-30T09:15:15.887Z","etag":null,"topics":["dictionary","find-key-in-dict","hacktoberfest","key-path","python-dictionary"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Agent-Hellboy.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-19T17:54:36.000Z","updated_at":"2023-11-09T18:53:58.000Z","dependencies_parsed_at":"2023-12-13T15:08:16.910Z","dependency_job_id":"c5ade336-7bc5-4663-b4af-ad54a75ce8d4","html_url":"https://github.com/Agent-Hellboy/trace-dkey","commit_stats":{"total_commits":44,"total_committers":5,"mean_commits":8.8,"dds":0.2272727272727273,"last_synced_commit":"2b46bcabb9e4ba87e74d649624a4fdb9d7b70324"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Agent-Hellboy%2Ftrace-dkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Agent-Hellboy%2Ftrace-dkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Agent-Hellboy%2Ftrace-dkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Agent-Hellboy%2Ftrace-dkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Agent-Hellboy","download_url":"https://codeload.github.com/Agent-Hellboy/trace-dkey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245090695,"owners_count":20559296,"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":["dictionary","find-key-in-dict","hacktoberfest","key-path","python-dictionary"],"created_at":"2024-10-11T10:13:18.189Z","updated_at":"2025-03-23T10:31:49.504Z","avatar_url":"https://github.com/Agent-Hellboy.png","language":"Python","readme":"trace-dkey\n==========\n\nPython library to trace path of a particular key inside a nested dict\n\n.. image:: https://img.shields.io/pypi/v/trace-dkey\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://github.com/Agent-Hellboy/trace-dkey/actions/workflows/python-app.yml/badge.svg\n    :target: https://github.com/Agent-Hellboy/trace-dkey/\n\n.. image:: https://img.shields.io/pypi/pyversions/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://img.shields.io/pypi/l/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://pepy.tech/badge/trace-dkey\n   :target: https://pepy.tech/project/trace-dkey\n\n.. image:: https://img.shields.io/pypi/format/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://coveralls.io/repos/github/Agent-Hellboy/trace-dkey/badge.svg?branch=main\n   :target: https://coveralls.io/github/Agent-Hellboy/trace-dkey?branch=main\n\nInstallation\n============\n\nFor stable version\n   - pip install trace-dkey\n\nFor development\n   - git clone https://github.com/Agent-Hellboy/trace-dkey\n   - cd trace-dkey\n   - python -m venv .venv\n   - source .venv/bin/activate\n\nDocumentation\n=============\n\nFor more details, you can refer to the `documentation \u003chttps://agent-hellboy.github.io/trace-dkey/\u003e`_.\n\n\nGeneral Info\n============\n\n- The value returned by the `trace` function is an array of paths, where each path is an array of dictionary keys.\n- Because of that, the library can be used in a practical way by taking advantage of this format.\n- In the example below we use the returned path to iterate over the dictionary keys and print the key value:\n\n.. code:: py\n\n    from trace_dkey import trace\n    l={'a':{'b':{'c':{'d':{'e':{'f':1}}}}}}\n\n    paths = trace(l,'f')\n\n    for path in paths:\n       dic = l\n       for key in path:\n          dic = dic[key]\n       print(dic)\n\n\n- This addresses a wide range of questions asked on StackOverflow about key inside a nested dict\n- At least 13 duplicate questions can be found on Stackoverflow\n- This can be tracked on https://you.com/search?q=find%20key%20in%20nested%20dictionary%20python\n\nAPI Examples\n============\n\nAdded example scripts demonstrating how to use trace-dkey with responses from popular APIs. These examples can be found in the `examples` folder:\n\n1. GitHub API Example (`github_api_example.py`): Demonstrates fetching repository information\n2. OpenWeatherMap API Example (`openweathermap_api_example.py`): Retrieves current weather data\n3. JSONPlaceholder API Example (`jsonplaceholder_api_example.py`): Shows how to interact with a mock REST API\n\nTo run these examples:\n\n1. Install the required dependencies:\n   ``pip install -r examples/requirements.txt``\n\n2. For the OpenWeatherMap example, you'll need to sign up for a free API key at https://openweathermap.org/ and set it as an environment variable:\n   ``export OPENWEATHERMAP_API_KEY=your_api_key_here``\n\n3. Run the examples:\n   ``python examples/github_api_example.py``\n   ``python examples/openweathermap_api_example.py``\n   ``python examples/jsonplaceholder_api_example.py``\n\nThese examples demonstrate how to use trace-dkey to find specific keys in nested JSON responses from real-world APIs.\n\n| Someone made a nice comparison of this lib(trace-dkey) with one of the famous lib(yamlpath) which is doing the similar thing\n\n.. image:: /images/img.png\n   :width: 600\n\nContributing\n============\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-hellboy%2Ftrace-dkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagent-hellboy%2Ftrace-dkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-hellboy%2Ftrace-dkey/lists"}