DEV Community

Caper B
Caper B

Posted on

Automating My Freelance Workflow with Python: A Step-by-Step Guide

Automating My Freelance Workflow with Python: A Step-by-Step Guide

As a freelance developer, I'm always looking for ways to streamline my workflow and increase productivity. One of the most effective tools I've found for achieving this is Python. In this article, I'll walk you through the specific steps I take to automate my freelance workflow using Python, including code examples and a monetization angle.

Step 1: Project Management with Trello and Python

I use Trello to manage my projects, and Python to automate repetitive tasks such as moving cards between lists and assigning due dates. To get started, you'll need to install the requests library and obtain a Trello API key.

import requests

# Trello API endpoint and API key
url = "https://api.trello.com/1/cards"
api_key = "YOUR_API_KEY"
api_token = "YOUR_API_TOKEN"

# Set card due date
def set_due_date(card_id, due_date):
    params = {
        "key": api_key,
        "token": api_token,
        "due": due_date
    }
    response = requests.put(f"{url}/{card_id}", params=params)
    return response.json()

# Example usage:
card_id = "1234567890"
due_date = "2024-09-16T14:00:00.000Z"
set_due_date(card_id, due_date)
Enter fullscreen mode Exit fullscreen mode

Step 2: Time Tracking with Python and Google Sheets

I use Google Sheets to track my time, and Python to automate the process of logging my hours. To get started, you'll need to install the gspread library and set up a Google Sheets spreadsheet.

import gspread
from oauth2client.service_account import ServiceAccountCredentials

# Set up Google Sheets API credentials
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
credentials = ServiceAccountCredentials.from_json_keyfile_name("client_secret.json", scope)

# Log time to Google Sheets
def log_time(project_name, hours_worked):
    client = gspread.authorize(credentials)
    sheet = client.open("Time Tracking").sheet1
    sheet.append_row([project_name, hours_worked])

# Example usage:
project_name = "Freelance Project"
hours_worked = 2
log_time(project_name, hours_worked)
Enter fullscreen mode Exit fullscreen mode

Step 3: Invoicing with Python and PayPal

I use PayPal to send invoices to my clients, and Python to automate the process of generating and sending invoices. To get started, you'll need to install the paypalrestsdk library and set up a PayPal business account.

import paypalrestsdk

# Set up PayPal API credentials
paypalrestsdk.configure({
    "mode": "sandbox",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET"
})

# Generate and send invoice
def send_invoice(client_name, amount):
    invoice = paypalrestsdk.Invoice({
        "merchant_info": {
            "email": "YOUR_EMAIL"
        },
        "billing_info": [
            {
                "email": client_name
            }
        ],
        "items": [
            {
                "name": "Freelance Services",
                "quantity": 1,
                "unit_price": {
                    "currency": "USD",
                    "value": amount
                }
            }
        ]
    })
    if invoice.create():
        print("Invoice created and sent successfully")
    else:
        print("Error creating and sending invoice")

# Example usage:
client_name = "client@example.com"
amount = 100
send_invoice(client_name, amount)
Enter fullscreen mode Exit fullscreen mode

Monetization Angle: Offering Automation Services to Clients

By automating my freelance workflow with Python, I'm able to offer automation services to my clients and increase my earning

Top comments (0)