credigraph 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: credigraph
3
+ Version: 0.1.0
4
+ Summary: Python client for the CrediGraph API
5
+ Author: Complex Data Lab
6
+ Project-URL: Homepage, https://huggingface.co/spaces/ekmpa/credibench-api
7
+ Requires-Dist: requests
@@ -0,0 +1,26 @@
1
+ # CrediBench Client
2
+
3
+ Python client for the CrediBench API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install credigraph
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from credigraph import query
15
+ print(query("apnews.com"))
16
+ print(query(["apnews.com", "cnn.com"]))
17
+ ```
18
+
19
+ With auth: `export HF_TOKEN=hf_...`
20
+
21
+ Or,
22
+ ```python
23
+ from credigraph import CrediGraphClient
24
+ c = CrediGraphClient(token="hf_...")
25
+ c.query("reuters.com")
26
+ ```
@@ -0,0 +1,4 @@
1
+ from .client import CrediGraphClient
2
+
3
+ def query(domain: str, **kwargs):
4
+ return CrediGraphClient(**kwargs).query(domain)
@@ -0,0 +1,26 @@
1
+ import os
2
+ import requests
3
+ from typing import List
4
+
5
+ DEFAULT_API_URL = "https://ekmpa-credibench-api.hf.space"
6
+
7
+ class CrediGraphClient:
8
+ def __init__(self, api_url=None, token=None):
9
+ self.api_url = api_url or DEFAULT_API_URL
10
+ self.token = token or os.getenv("HF_TOKEN")
11
+
12
+ def query_domain(self, domain: str):
13
+ url = f"{self.api_url}/by_domain/{domain}"
14
+ headers = {}
15
+ if self.token:
16
+ headers["Authorization"] = f"Bearer {self.token}"
17
+
18
+ r = requests.get(url, headers=headers, timeout=10)
19
+ r.raise_for_status()
20
+ return r.json()
21
+
22
+ def query(self, domains: List[str] | str):
23
+ if isinstance(domains, str):
24
+ return self.query_domain(domains)
25
+
26
+ return [self.query_domain(d) for d in domains]
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: credigraph
3
+ Version: 0.1.0
4
+ Summary: Python client for the CrediGraph API
5
+ Author: Complex Data Lab
6
+ Project-URL: Homepage, https://huggingface.co/spaces/ekmpa/credibench-api
7
+ Requires-Dist: requests
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ credibench/__init__.py
4
+ credibench/client.py
5
+ credigraph.egg-info/PKG-INFO
6
+ credigraph.egg-info/SOURCES.txt
7
+ credigraph.egg-info/dependency_links.txt
8
+ credigraph.egg-info/requires.txt
9
+ credigraph.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests
@@ -0,0 +1 @@
1
+ credibench
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "credigraph"
7
+ version = "0.1.0"
8
+ description = "Python client for the CrediGraph API"
9
+ authors = [{name = "Complex Data Lab"}]
10
+ dependencies = ["requests"]
11
+
12
+ [project.urls]
13
+ Homepage = "https://huggingface.co/spaces/ekmpa/credibench-api"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+