bdds

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

EPO BDDS Go Client

CI Go Reference Go Report Card

A Go client for the European Patent Office's Bulk Data Distribution Service (BDDS) REST API - product discovery, delivery listing, and downloading of bulk datasets such as DOCDB, INPADOC, and EP full-text.

Overview

  • Product discovery - list products, fetch a product with its deliveries, look up a product by name, get the latest delivery.
  • File downloads - stream a delivery file to any io.Writer, with an optional progress callback for large files.
  • Automatic auth - OAuth2 password grant; tokens are cached and refreshed before expiry. Every endpoint requires an EPO account.
  • Robust requests - retry with backoff and automatic re-authentication on expiry; typed errors for the common failure cases.

Installation

go get github.com/patent-dev/epo-bdds

Getting access

Every BDDS request needs an EPO account, including the product list and free products; paid products also need a subscription to the product. The client authenticates via OAuth2 password grant. Without credentials, requests fail with an *AuthError (BDDS redirects them to the interactive EPO login).

  1. Open the BDDS portal to browse the product catalogue, then start sign-in / registration.

  2. Sign in with your EPO account, or create one at the EPO login.

  3. Subscribe to the products you need (free products need no subscription, but still need the account).

  4. Export your EPO credentials for the client and demo:

    export EPO_BDDS_USERNAME=...
    export EPO_BDDS_PASSWORD=...
    

Quick start

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    bdds "github.com/patent-dev/epo-bdds"
)

func main() {
    // Every BDDS endpoint requires an EPO account.
    client, err := bdds.NewClient(&bdds.Config{
        Username: os.Getenv("EPO_BDDS_USERNAME"),
        Password: os.Getenv("EPO_BDDS_PASSWORD"),
    })
    if err != nil {
        log.Fatal(err)
    }

    products, err := client.ListProducts(context.Background())
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Found %d products\n", len(products))
    for _, p := range products {
        fmt.Printf("- [%d] %s\n", p.ID, p.Name)
    }
}

Usage

Configuration
config := &bdds.Config{
    Username:   "your-username",                          // required: EPO account
    Password:   "your-password",                          // required
    BaseURL:    "https://publication-bdds.apps.epo.org",  // default
    UserAgent:  "YourApp/1.0",                            // optional
    MaxRetries: 3,                                        // default: 3
    RetryDelay: time.Second,                              // delay between retries, default: 1s
    Timeout:    30 * time.Second,                         // request timeout, default: 30s
}

client, err := bdds.NewClient(config)

RetryDelay and Timeout are time.Duration values.

Product discovery
// List all available products.
products, err := client.ListProducts(ctx)

// Get a product with its deliveries.
product, err := client.GetProduct(ctx, 3) // EP DocDB front file

// Find a product by name.
product, err := client.GetProductByName(ctx, "EP DocDB front file")

// Get the most recent delivery for a product.
delivery, err := client.GetLatestDelivery(ctx, 3)

GetProduct returns a *ProductWithDeliveries; each delivery lists its files:

for _, d := range product.Deliveries {
    fmt.Printf("%s - %d files\n", d.DeliveryName, len(d.Files))
}
File downloads

With the product, delivery, and file IDs, a file streams to any io.Writer:

f, err := os.Create("download.zip")
if err != nil {
    log.Fatal(err)
}
defer f.Close()

err = client.DownloadFile(ctx, productID, deliveryID, fileID, f)

Use DownloadFileWithProgress for a progress callback on large files:

err = client.DownloadFileWithProgress(ctx, 3, 12345, 67890, f,
    func(bytesWritten, totalBytes int64) {
        fmt.Printf("\rProgress: %.1f%%", float64(bytesWritten)*100/float64(totalBytes))
    })
Common product IDs
ID Name Description
3 EP DocDB front file Bibliographic data (front file)
4 EP full-text data - front file Full-text patent data
14 EP DocDB back file Bibliographic data (back file)
17 PATSTAT Global Patent statistics database
18 PATSTAT EP Register EP register data
Demo

An interactive demo exercises every method. Set credentials and run it:

export EPO_BDDS_USERNAME=your-username
export EPO_BDDS_PASSWORD=your-password
cd demo && go run demo.go

See demo/README.md for details.

Error handling

The library returns typed errors you can match with errors.As:

var authErr *bdds.AuthError
if errors.As(err, &authErr) {
    fmt.Printf("auth failed (status %d): %s\n", authErr.StatusCode, authErr.Message)
}

var notFound *bdds.NotFoundError
if errors.As(err, &notFound) {
    fmt.Printf("%s not found: %s\n", notFound.Resource, notFound.ID)
}

var rateLimit *bdds.RateLimitError
if errors.As(err, &rateLimit) {
    fmt.Printf("rate limited, retry after %d seconds\n", rateLimit.RetryAfter)
}

Testing

make test              # unit tests (mock HTTP server, race)
make test-integration  # integration tests against the real API, needs credentials
make lint

Integration tests require valid EPO BDDS credentials and skip gracefully when they are not set or a product is not accessible for your account:

export EPO_BDDS_USERNAME=your-username
export EPO_BDDS_PASSWORD=your-password

Regenerating from OpenAPI

The typed code under generated/ is produced from the hand-crafted openapi.yaml with oapi-codegen. If you change the spec, regenerate it:

make generate

Part of the patent.dev open-source patent data ecosystem:

  • epo-ops - EPO Open Patent Services client (bibliographic, full text, families, legal status, images)
  • uspto-odp - USPTO Open Data Portal client (patents, PTAB, TSDR, full text)
  • dpma-connect-plus - DPMA Connect Plus client (patents, designs, trademarks)

The bulk-file-loader uses these libraries for automated patent data downloads.

License

MIT - Funktionslust GmbH / patent.dev.

Documentation

Overview

Package bdds provides a Go client for the European Patent Office's Bulk Data Distribution Service (BDDS), covering product discovery, delivery listing, and downloading of bulk patent datasets such as DOCDB, INPADOC, and EP full-text.

Index

Examples

Constants

View Source
const DefaultUserAgent = "epo-bdds-go/" + Version + " (patent.dev; +https://github.com/patent-dev/epo-bdds)"

DefaultUserAgent identifies this library in outbound requests.

View Source
const Version = "0.2.4"

Version is the library version. It surfaces through the default User-Agent.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthError

type AuthError struct {
	StatusCode int
	Message    string
}

AuthError represents an authentication error

func (*AuthError) Error

func (e *AuthError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the main EPO BDDS API client

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new EPO BDDS API client. Every BDDS endpoint requires an EPO account, including the product list and free products; without credentials requests fail with an *AuthError.

Example
package main

import (
	"fmt"

	bdds "github.com/patent-dev/epo-bdds"
)

func main() {
	// Every BDDS endpoint requires an EPO account; paid products also need
	// a subscription to that product.
	client, err := bdds.NewClient(&bdds.Config{
		Username: "your-epo-username",
		Password: "your-epo-password",
	})
	if err != nil {
		panic(err)
	}
	// client is ready; call ListProducts, GetProduct, DownloadFile, etc.
	fmt.Println(client != nil)
}
Output:
true

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, productID, deliveryID, fileID int, dst io.Writer) error

DownloadFile downloads a file to the provided writer

func (*Client) DownloadFileWithProgress

func (c *Client) DownloadFileWithProgress(ctx context.Context, productID, deliveryID, fileID int, dst io.Writer, progressFn func(bytesWritten, totalBytes int64)) error

DownloadFileWithProgress downloads a file to the provided writer with progress callback. If an attempt fails after partially writing to dst, the retry rewinds a seekable destination (truncating it when supported, as *os.File is) before copying again, so the output is always byte-exact or the call errors - never silently corrupted. A non-seekable destination with partial data fails fast instead of retrying.

func (*Client) GetLatestDelivery

func (c *Client) GetLatestDelivery(ctx context.Context, productID int) (*Delivery, error)

GetLatestDelivery returns the most recent delivery for a product

func (*Client) GetProduct

func (c *Client) GetProduct(ctx context.Context, productID int) (*ProductWithDeliveries, error)

GetProduct returns detailed information about a specific product including deliveries

func (*Client) GetProductByName

func (c *Client) GetProductByName(ctx context.Context, name string) (*Product, error)

GetProductByName finds a product by name

func (*Client) ListProducts

func (c *Client) ListProducts(ctx context.Context) ([]*Product, error)

ListProducts returns all available BDDS products

type Config

type Config struct {
	Username   string        // EPO BDDS username
	Password   string        // EPO BDDS password
	BaseURL    string        // Base URL for API (default: https://publication-bdds.apps.epo.org)
	UserAgent  string        // Optional custom user agent
	MaxRetries int           // Maximum number of retries (default: 3)
	RetryDelay time.Duration // Delay between retries (default: 1s)
	Timeout    time.Duration // Request timeout (default: 30s)
}

Config holds client configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

type Delivery

type Delivery struct {
	DeliveryID                  int
	DeliveryName                string
	DeliveryPublicationDatetime time.Time
	DeliveryExpiryDatetime      *time.Time
	Files                       []*DeliveryFile
}

Delivery represents a product delivery

type DeliveryFile

type DeliveryFile struct {
	FileID                  int
	FileName                string
	FileSize                string
	FileChecksum            string
	FilePublicationDatetime time.Time
}

DeliveryFile represents a file in a delivery

type NotFoundError

type NotFoundError struct {
	Resource string
	ID       string
}

NotFoundError represents a resource not found error

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Product

type Product struct {
	ID          int
	Name        string
	Description string
}

Product represents a BDDS product

type ProductWithDeliveries

type ProductWithDeliveries struct {
	ID          int
	Name        string
	Description string
	Deliveries  []*Delivery
}

ProductWithDeliveries represents a product with its deliveries

type RateLimitError

type RateLimitError struct {
	RetryAfter int // seconds
}

RateLimitError represents a rate limit error

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

Directories

Path Synopsis
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL