Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
bing-webmaster-tools
Advanced tools
An async Python client library for the Bing Webmaster Tools API, providing a clean interface for managing websites, analyzing search traffic, handling content submissions, and more.
The Bing Webmaster API Client is a modern, async Python library that provides a comprehensive interface to Bing Webmaster Tools API. The library is designed with a focus on developer experience, type safety, and reliability, offering structured access to all Bing Webmaster Tools features through a clean, domain-driven API.
Install the package using pip:
pip install bing-webmaster-tools
Get your API key from Bing Webmaster Tools
Set your API key as an environment variable:
export BING_WEBMASTER_API_KEY=your_api_key_here
Or use a .env file:
BING_WEBMASTER_API_KEY=your_api_key_here
Look under the examples subdirectory to see boilerplate scripts which can help you get started. These assume you are using the environment variable BING_WEBMASTER_API_KEY
as described in the Basic Setup.
The client supports several ways to provide authentication:
client = BingWebmasterClient(Settings.from_env())
client = BingWebmasterClient(Settings(api_key="your_api_key_here"))
from dotenv import load_dotenv
load_dotenv() # Load from .env file
client = BingWebmasterClient(Settings.from_env())
The client can be initialized in several ways:
from bing_webmaster_tools import Settings, BingWebmasterClient
# Using environment variables
async with BingWebmasterClient(Settings.from_env()) as client:
sites = await client.sites.get_sites()
# Direct initialization
settings = Settings(
api_key="your_api_key",
timeout=30, # Custom timeout
max_retries=5 # Custom retry count
)
async with BingWebmasterClient(settings) as client:
sites = await client.sites.get_sites()
# Manual session management
client = BingWebmasterClient(Settings.from_env())
await client.init()
try:
sites = await client.sites.get_sites()
finally:
await client.close()
The client behavior can be customized through the Settings class:
from bing_webmaster_tools import Settings
settings = Settings(
# Required
api_key="your_api_key", # Also via BING_WEBMASTER_API_KEY env var
# Optional with defaults
base_url="https://ssl.bing.com/webmaster/api.svc/json",
timeout=30, # Request timeout in seconds
max_retries=3, # Maximum number of retry attempts
rate_limit_calls=10, # Number of calls allowed per period
rate_limit_period=1, # Rate limit period in seconds
disable_destructive_operations=False
# Disable destructive operations, if you want to prevent accidental deletions etc.
)
Environment variables can be used with the BING_WEBMASTER_
prefix:
BING_WEBMASTER_API_KEY=your_api_key
BING_WEBMASTER_TIMEOUT=60
BING_WEBMASTER_MAX_RETRIES=5
The client provides structured error handling:
from bing_webmaster_tools.exceptions import (
BingWebmasterError,
AuthenticationError,
RateLimitError
)
async def handle_api_calls():
try:
await client.sites.get_sites()
except AuthenticationError:
# Handle authentication issues
print("Check your API key")
except RateLimitError:
# Handle rate limiting
print("Too many requests")
except BingWebmasterError as e:
# Handle other API errors
print(f"API error: {e.message}, Status: {e.status_code}")
The client includes built-in rate limiting:
To turn off rate limiting, simply set the rate limit configuration variables to None
.
The client provides access to different API functionalities through specialized services. For full details on available services and methods, refer to the API documentation.
To install from source for development:
# Clone the repository
git clone https://github.com/merj/bing-webmaster-tools
cd bing-webmaster-tools
# Install poetry if you haven't already
pip install poetry
# Install dependencies and setup development environment
poetry install
FAQs
Python wrapper for the Bing Webmaster Tools API
We found that bing-webmaster-tools 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.