Get started with the MapFlow Python SDK in 5 minutes!
pip install mapflow-co-sdk- Sign up at mapflow.co
- Navigate to Settings > API Keys
- Create a new API key
- Copy your key (keep it secure!)
from mapflow import MapFlowClient
client = MapFlowClient(api_key="your-api-key")from mapflow import CustomerType
# Create a company customer
customer = client.create_customer({
"customer_type": CustomerType.COMPANY,
"company_name": "My First Company",
"email": "contact@company.com",
"billing_city": "Paris",
"billing_country": "FR"
})
print(f"Created customer: {customer.display_name}")
print(f"Customer ID: {customer.id}")location = client.create_delivery_location({
"customer": customer.id,
"name": "Main Office",
"address": "123 Main Street",
"zip_code": "75001",
"city": "Paris",
"country": "FR",
"latitude": 48.8566,
"longitude": 2.3522
})
print(f"Created location: {location.name}")from mapflow import WarehouseType
warehouse = client.create_warehouse({
"name": "Central Warehouse",
"code": "MAIN-01",
"warehouse_type": WarehouseType.HUB,
"address": "456 Warehouse Blvd",
"zip_code": "93200",
"city": "Saint-Denis",
"country": "FR",
"is_start_point": True,
"is_end_point": True
})
print(f"Created warehouse: {warehouse.name}")from mapflow import ItemType
product = client.create_delivery_item({
"name": "Laptop Computer",
"item_type": ItemType.PRODUCT,
"weight": 2.5,
"weight_unit": "kg",
"declared_value": 1000.0,
"currency": "EUR",
"is_fragile": True
})
print(f"Created product: {product.name}")from mapflow import VehicleType, EnergyType
vehicle = client.create_vehicle({
"name": "Delivery Van 01",
"license_plate": "AB-123-CD",
"vehicle_type": VehicleType.VAN_MEDIUM,
"brand": "Renault",
"model": "Master",
"energy_type": EnergyType.DIESEL,
"max_weight_kg": 1500,
"max_volume_m3": 12.0,
"assigned_warehouses": [str(warehouse.id)]
})
print(f"Created vehicle: {vehicle.name}")# List all customers
customers = client.list_customers()
print(f"Total customers: {customers.count}")
# With filtering
active_customers = client.list_customers(is_active=True)# Search customers
results = client.list_customers(search="Company")
# Advanced filtering
locations = client.list_delivery_locations(
city="Paris",
has_coordinates=True,
truck_access=True
)from mapflow import NotFoundError, ValidationError
try:
customer = client.get_customer(customer_id)
except NotFoundError:
print("Customer not found")
except ValidationError as e:
print(f"Validation error: {e.message}")# Partial update
client.patch_customer(customer_id, {
"notes": "Updated notes"
})
# Full update
client.update_customer(customer_id, {
# ... all fields required
})client.delete_customer(customer_id)- Read the full documentation
- Check out basic examples
- Explore advanced features
- Review the API documentation
- 📧 Email: support@mapflow.co
- 📚 Documentation: https://mapflow.readme.io/reference
- 🐛 Issues: https://github.com/mapflow/sdk-python/issues
# Activate multiple customers at once
client.customer_bulk_action(
action="activate",
customer_ids=[id1, id2, id3]
)page = 1
while True:
response = client.list_customers(page=page)
for customer in response.results:
print(customer.display_name)
if not response.next:
break
page += 1Create customer, location, contact, and hours in one call:
global_customer = client.create_global_customer({
"customer_type": "company",
"company_name": "Quick Start Corp",
"delivery_location": {
"name": "Main Office",
"address": "123 Street",
"zip_code": "75001",
"city": "Paris",
"country": "FR"
},
"contact": {
"first_name": "John",
"last_name": "Doe",
"emails": ["john@example.com"]
},
"opening_hours": [
{
"day_of_week": 0, # Monday
"opening_time": "09:00",
"closing_time": "18:00"
}
]
})Happy coding! 🚀