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.
- credigraph-0.1.0/PKG-INFO +7 -0
- credigraph-0.1.0/README.md +26 -0
- credigraph-0.1.0/credibench/__init__.py +4 -0
- credigraph-0.1.0/credibench/client.py +26 -0
- credigraph-0.1.0/credigraph.egg-info/PKG-INFO +7 -0
- credigraph-0.1.0/credigraph.egg-info/SOURCES.txt +9 -0
- credigraph-0.1.0/credigraph.egg-info/dependency_links.txt +1 -0
- credigraph-0.1.0/credigraph.egg-info/requires.txt +1 -0
- credigraph-0.1.0/credigraph.egg-info/top_level.txt +1 -0
- credigraph-0.1.0/pyproject.toml +13 -0
- credigraph-0.1.0/setup.cfg +4 -0
|
@@ -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,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 @@
|
|
|
1
|
+
|
|
@@ -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"
|