DEV Community

Caper B
Caper B

Posted on

How I Automate My Freelance Workflow with Python to Increase Earnings by 30%

How I Automate My Freelance Workflow with Python to Increase Earnings by 30%

As a freelance developer, managing multiple projects and clients can be overwhelming. However, by leveraging the power of Python, I've been able to automate many aspects of my workflow, resulting in increased productivity and earnings. In this article, I'll share my step-by-step approach to automating my freelance workflow using Python.

Step 1: Project Management Automation

I use the github API to automate project management tasks such as creating new repositories, setting up project boards, and assigning issues. Here's an example of how I use the requests library to create a new repository:

import requests

def create_repository(repo_name, repo_description):
    url = "https://api.github.com/repos"
    headers = {
        "Authorization": "Bearer YOUR_GITHUB_TOKEN",
        "Content-Type": "application/json"
    }
    data = {
        "name": repo_name,
        "description": repo_description
    }
    response = requests.post(url, headers=headers, json=data)
    return response.json()

# Example usage:
repo_name = "my-new-repo"
repo_description = "This is my new repository"
create_repository(repo_name, repo_description)
Enter fullscreen mode Exit fullscreen mode

This script creates a new repository with the specified name and description.

Step 2: Time Tracking Automation

Accurate time tracking is crucial for freelancers to ensure they're getting paid for their work. I use the toggl API to automate time tracking. Here's an example of how I use the requests library to start a new timer:

import requests

def start_timer(project_id, task_name):
    url = "https://api.toggl.com/reports/v8/details"
    headers = {
        "Authorization": "Bearer YOUR_TOGGL_TOKEN",
        "Content-Type": "application/json"
    }
    data = {
        "project_id": project_id,
        "task": task_name
    }
    response = requests.post(url, headers=headers, json=data)
    return response.json()

# Example usage:
project_id = 123456
task_name = "Development"
start_timer(project_id, task_name)
Enter fullscreen mode Exit fullscreen mode

This script starts a new timer for the specified project and task.

Step 3: Invoicing Automation

I use the stripe API to automate invoicing and payment processing. Here's an example of how I use the stripe library to create a new invoice:

import stripe

def create_invoice(client_id, amount):
    stripe.api_key = "YOUR_STRIPE_SECRET_KEY"
    invoice = stripe.Invoice.create(
        customer=client_id,
        amount=amount,
        currency="usd"
    )
    return invoice

# Example usage:
client_id = "cus_123456"
amount = 1000
create_invoice(client_id, amount)
Enter fullscreen mode Exit fullscreen mode

This script creates a new invoice for the specified client and amount.

Step 4: Client Onboarding Automation

I use the zapier API to automate client onboarding tasks such as sending welcome emails and setting up project management tools. Here's an example of how I use the requests library to send a welcome email:


python
import requests

def send_welcome_email(client_email):
    url = "https://api.zapier.com/v1/send-email"
    headers = {
        "Authorization": "Bearer YOUR_ZAPIER_TOKEN",
        "Content-Type": "application/json"
    }
    data = {
        "to": client_email,
        "subject": "Welcome to our team!",
        "body": "Welcome to our team! We're excited to work with you."
    }
    response = requests.post(url, headers=headers, json=data)
    return response.json()

# Example usage:
client_email = "client@example.com"
send_w
Enter fullscreen mode Exit fullscreen mode

Top comments (0)