Skip to content

Commit

Permalink
Merge pull request #19 from essteer/feat-api-docs
Browse files Browse the repository at this point in the history
docs: Add example requests to FastAPI docs
  • Loading branch information
essteer authored Sep 23, 2024
2 parents ba6511f + 3eed7cd commit 6e1a248
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
26 changes: 26 additions & 0 deletions src/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@
Weighted random selections are made from those lists to approximate authentic header data patterns.
A basic header template with common attributes — like [`"Upgrade-Insecure-Requests": "1"`](https://stackoverflow.com/questions/31950470/what-is-the-upgrade-insecure-requests-http-header/32003517#32003517) — is also provided and defaults to the most common referer and user-agent data from the above lists.
## Requests
The code examples below illustrate methods for making API calls in different languages.
### cURL
```console
$ curl -X GET 'https://masquer.fly.dev/masq?ua=true&rf=false&hd=false' -H 'accept: application/json'
```
### JavaScript (using `fetch`)
```javascript
fetch('https://masquer.fly.dev/masq?ua=true&rf=false&hd=false')
.then(response => response.json())
.then(data => console.log(data))
```
### Python (using `requests`)
```python
import requests
response = requests.get("https://masquer.fly.dev/masq", params={"ua": True, "rf": False, "hd": False})
print(response.json())
```
"""

SUMMARY = "A tool to generate random user-agent and referer data for HTTP requests."
Expand Down
6 changes: 3 additions & 3 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def update_useragents() -> bool:
with open(os.path.join(ASSETS_DIR, "useragents.json"), "w") as f:
json.dump(json_string, f)

logger.info("Fetched useragent data")
logger.info("Fetched user-agent data")
return True

except Exception as e:
logger.error(f"Error fetching useragent data: {e}")
logger.error(f"Error fetching user-agent data: {e}")
return False


Expand Down Expand Up @@ -130,7 +130,7 @@ def update_assets() -> bool:
f.write("USERAGENT_WEIGHTS = " + str(useragent_weights))
f.write("\n")

logger.info("Saved useragent and referer JSON data to assets.py")
logger.info("Saved user-agent and referer JSON data to assets.py")
return True

except FileNotFoundError:
Expand Down

0 comments on commit 6e1a248

Please sign in to comment.