
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
llamaapi-llamasearch
Advanced tools
Flexible API client and server utilities for LlamaSearch.ai applications.
pip install llamaapi
from llamaapi import create_client, ApiKeyAuth, LoggingMiddleware
# Create API client with API key authentication
client = create_client(
base_url="https://api.example.com/v1",
auth=ApiKeyAuth("your-api-key"),
middleware=[LoggingMiddleware()],
timeout=10,
retries=3,
)
# Make GET request
response = client.get("users")
response.raise_for_status()
users = response.json()
print(f"Found {len(users)} users")
# Make POST request
new_user = {"name": "John Doe", "email": "john.doe@example.com"}
response = client.post("users", json=new_user)
response.raise_for_status()
created_user = response.json()
print(f"Created user: {created_user['name']}")
from llamaapi import create_api, Request, Response, HttpMethod
# Create API instance
api = create_api(name="My API", version="1.0.0")
# Define a route
@api.route("/users", methods=HttpMethod.GET)
async def get_users(request: Request) -> Response:
# Get data from your data source
users = [{"id": 1, "name": "John"}, {"id": 2, "name": "Jane"}]
return Response().with_json(users)
# Define a route with path parameters
@api.route("/users/{user_id}", methods=HttpMethod.GET)
async def get_user(request: Request) -> Response:
user_id = request.path_params.get("user_id")
# Get user data from your data source
user = {"id": user_id, "name": "John Doe"}
return Response().with_json(user)
For more detailed examples, see the examples
directory.
from llamaapi import create_client, ApiKeyAuth
client = create_client(
base_url="https://api.example.com",
auth=ApiKeyAuth(api_key="your-api-key"),
)
from llamaapi import create_client, BearerAuth
client = create_client(
base_url="https://api.example.com",
auth=BearerAuth(token="your-token"),
)
from llamaapi import create_client, OAuth2Auth
auth = OAuth2Auth(
token_url="https://auth.example.com/oauth/token",
client_id="your-client-id",
client_secret="your-client-secret",
scope="read write",
)
# Use client credentials flow to get a token
auth.client_credentials_flow()
client = create_client(
base_url="https://api.example.com",
auth=auth,
)
from llamaapi import (
create_client,
LoggingMiddleware,
RetryMiddleware,
HeadersMiddleware,
)
middleware = [
LoggingMiddleware(log_headers=True),
RetryMiddleware(max_retries=3),
HeadersMiddleware({"User-Agent": "MyApp/1.0"}),
]
client = create_client(
base_url="https://api.example.com",
middleware=middleware,
)
from llamaapi import create_client, MemoryCache, FileCache
# Memory cache
client = create_client(
base_url="https://api.example.com",
cache=MemoryCache(max_size=100),
)
# File cache
client = create_client(
base_url="https://api.example.com",
cache=FileCache(cache_dir=".cache"),
)
from llamaapi import create_client
client = create_client(base_url="https://api.example.com")
# Stream large data
with client.stream("GET", "large-dataset") as response:
for chunk in response.iter_content(chunk_size=1024):
process_chunk(chunk)
from llamaapi import api, validate_json_schema
user_schema = {
"type": "object",
"properties": {
"name": {"type": "string", "minLength": 2},
"email": {"type": "string", "format": "email"},
},
"required": ["name", "email"],
}
@api.route(
"/users",
methods=HttpMethod.POST,
middleware=[validate_json_schema(user_schema)]
)
async def create_user(request: Request) -> Response:
user_data = request.json()
# Create user with validated data
return Response(status_code=201).with_json(new_user)
from llamaapi import api, require_auth
# Define authentication middleware
async def auth_middleware(request: Request) -> Request:
api_key = request.headers.get("X-API-Key")
if api_key == "secret-key":
request.context["user"] = {"id": "admin", "role": "admin"}
return request
api.add_middleware(auth_middleware)
# Require authentication for specific routes
@api.route("/admin-only", methods=HttpMethod.GET)
@require_auth
async def admin_only(request: Request) -> Response:
user = request.context["user"] # This is guaranteed to exist
return Response().with_json({"message": f"Hello, {user['id']}"})
MIT License
FAQs
A flexible API client and server utilities package
We found that llamaapi-llamasearch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.