Hosting Library server

Hi there,

First of all, great project!

One of the biggest hurdles I’ve encountered so far is the availability of libraries. For most designs I still have to import components from external libraries. Back in the Eagle 3.x days, a key advantage was the user‑contributed library ecosystem. Some good, some bad, but nevertheless contributing to the overall knowledge-base.

I can understand, that the developing team has not the capacity to curate such at the moment. Therefore my take would be, how one could include such user-contribution to the project.

I saw in the workspace config dialog that it is possible to connect further services via API.

Is there any description to be found how a second library API server may be used here? What API functions needs this secondary library server to serve?

My background to this is, that I would like to host an internal library server for our organisation. On the further perspective I would then like to open this server to the public.

What do you think?

regards

MW

Hi @Walter11,

Thanks :smiling_face:

Absolutely. This is regularly reported by users, and is clearly something that we have to work on. For long term, we have to extend our libraries a lot, but that will take a huge amount of resources which we don’t have at the moment. So we also need short-time solutions, for example to get parts on-demand from services like SnapEDA or pcblibraries.com, or to simply share “unofficial” libraries between users. The Eagle & KiCad importers are also made to provide a short-term solution for the library problem.

Regarding your concrete question: The API for providing libraries is documented here:

When you host a server that implements this API, anyone who has access to the server can add it to the workspace settings and will get the libraries from that server.

The implementation of such a server can actually be quite trivial. In fact, our official server is just a python script that periodically pulls the libraries from GitHub, parses their metadata, saves a JSON file according the API spec, and a static web server delivers that JSON file :wink:

Also for companies, I actually do have plans to provide some kind of web panel where they can host their own (private) libraries for easy library deployment within an organization. We should provide paid services to professional users anyway (like an official customer support), to ensure a sustainable funding of the development for long term. The ability of managing company libraries could be part of that paid services (fully optional of course – it will always be possible to implement & host such a server for free by yourself).

As soon as we have built such a system for companies, actually it may also be used to share libraries publicly :thinking:

Anyway, those are ideas for the future – implementing the API by yourself, and sharing the URL to other users, is already possible today.

Just in case you would be interested in an official solution of internal library management, and official customer support, as part of a paid subscription – please let me know (feel free to PM me, or mail to Contact | LibrePCB). Instead of building something on my own and hoping that companies are interested in buying it, it would be great to have a concrete customer to better understand the needs and to start building up the services together :slightly_smiling_face:

Many thanks for your prompt reply. With a lot of discussion with my GPT friend, I was able to get it up and running!. Here is my documentation for the process

______________________________________________________________________

LibrePCB Library Server on GitLab Pages

This guide explains how to publish your own LibrePCB library server using GitLab Pages.

Starting point: You already created a LibrePCB library:

Test_Library.lplib

The goal is to host it so LibrePCB can install it via a remote library source.


1. Create a Git Repository and Enable GitLab Pages

Create a new project on your GitLab instance.

Example:

librepcb-library-server

Clone it locally:

git clone git@gitlab.git.nrw:username/librepcb-library-server.git
cd librepcb-library-server

Create the GitLab Pages configuration file:

.gitlab-ci.yml

Content:

pages:
  stage: deploy
  script:
    - echo "Publishing LibrePCB library server"
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

GitLab Pages publishes everything inside:

public/

Don’t forget to make GitLab Pages publicly accessible.
In your GitLab project:

Go to Settings
→ Open General
→ Find Visibility, project features, permissions
→ Look for Pages
→ Set it to Everyone

After pushing, the site will be available at:

https://<project>.pages.git.nrw/

2. Create the Directory Structure

Create the directories:

mkdir -p public/api/v1/libraries
mkdir -p public/libs
mkdir -p libraries
mkdir -p scripts

Directory purpose:

libraries/      → editable LibrePCB libraries (sources)
public/libs/    → zipped libraries for download
public/api/     → API JSON for LibrePCB
scripts/        → helper scripts

3. Add the Library Source

Copy your LibrePCB library into:

libraries/Test_Library.lplib

The library should contain:

.librepcb-lib
library.lp
sym/
pkg/
cmp/
dev/

4. Create the Library ZIP

LibrePCB downloads libraries as ZIP archives.

Create the ZIP file:

cd libraries/Test_Library.lplib
zip -r ../../public/libs/Test_Library.lplib.zip . -x ".lock"
cd ../../

Verify the archive:

unzip -l public/libs/Test_Library.lplib.zip

The root must contain:

.librepcb-lib
library.lp

5. Create the LibrePCB API JSON

Create the API endpoint file:

public/api/v1/libraries/v2

Example JSON:

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": {
        "default": "Test Library"
      },
      "description": {
        "default": "Example LibrePCB library"
      },
      "keywords": {
        "default": "example,test"
      },
      "author": "Your Name",
      "version": "0.1",
      "deprecated": false,
      "url": "https://gitlab.git.nrw/username/librepcb-library-server",
      "dependencies": [],
      "component_categories": 0,
      "package_categories": 0,
      "symbols": 0,
      "packages": 0,
      "components": 0,
      "devices": 0,
      "recommended": true,
      "updated_at": "2026-06-04T12:00:00+00:00",
      "format_version": "2",
      "icon_url": null,
      "download_url": "https://<project>.pages.git.nrw/libs/Test_Library.lplib.zip",
      "download_size": 12345,
      "download_sha256": "abcdef123456..."
    }
  ]
}

Explanation of JSON Fields

Field Description
uuid Library UUID from library.lp
name Human readable library name
description Short description
keywords Search keywords
author Library author
version Library version
deprecated Mark library obsolete
url Homepage or repository
dependencies UUIDs of required libraries
component_categories Number of component categories
package_categories Number of package categories
symbols Number of symbols
packages Number of packages
components Number of components
devices Number of devices
recommended Suggest installation
updated_at ISO‑8601 timestamp
format_version Library format version
icon_url Optional icon
download_url Direct ZIP download link
download_size ZIP file size in bytes
download_sha256 SHA256 checksum

6. Calculate File Size and SHA256

Calculate ZIP size:

stat -c %s public/libs/Test_Library.lplib.zip

Calculate SHA256:

sha256sum public/libs/Test_Library.lplib.zip

Insert these values into the JSON.


7. Push to GitLab

Commit everything:

git add .
git commit -m "Add Test Library"
git push

GitLab CI will publish the Pages site.

Test the API:

curl https://<project>.pages.git.nrw/api/v1/libraries/v2 | jq

this should return a working json file

8. Add the Server to LibrePCB

Open LibrePCB:

Workspace Settings → Internet

Enter:

https://<project>.pages.git.nrw/api/v1/libraries/v2

LibrePCB should now list and install the library.


9. Automation Script

Create:

scripts/build_library.sh

Content:

#!/bin/bash

LIBNAME=Test_Library.lplib
ZIP=public/libs/$LIBNAME.zip

cd libraries/$LIBNAME

zip -r ../../$ZIP . -x ".lock"

cd ../../

SIZE=$(stat -c %s $ZIP)
SHA=$(sha256sum $ZIP | cut -d " " -f1)

echo "Size: $SIZE"
echo "SHA256: $SHA"

Make executable:

chmod +x scripts/build_library.sh

Run:

scripts/build_library.sh

The script rebuilds the ZIP and prints the values needed for the JSON.


Result

You now have a fully working LibrePCB library server hosted on GitLab Pages.

Automatic Script

For those who want to use this setup in a production environment, automating the process is highly recommended. A script can extract the required information, generate the ZIP archives, and create the necessary directory structure and JSON metadata automatically.

You can find my current implementation attached: create_librePCB_json.sh. Just copy your libraries in the /libraries folder and the .sh script in the scripts folder of your git repo.

Feel free to use it and let me know if you have any suggestions or improvements.

Final advice: LibrePCB uses the version number in library.lp to determine whether a remote library needs to be updated. Therefore, whenever you publish a new version of your library, remember to update this version number as well.

Here you can find the script file create_librePCB_json.sh

Somehow I was not able to upload it here. Even as ZIP always an error resulted.

Nice! Just two comments:

This needs a small correction: The URL added to the workspace settings must be without the /api/v1/... path.

And regarding the script: Please note that you should also take care of the file format version. Otherwise, the library management won’t work properly when a new major release of LibrePCB comes out. To ensure a smooth transition from one major version to the next, I recommend the following:

  • In the JSON, the “format_version” should not be hardcoded. Read this information from the file “.librepcb-lib”. Extract its first line – this is the format version. Currently it is “2”, but for LibrePCB 3.x it will be “3” and so on.
  • Adjust the API path for every new major release. LibrePCB 2.x calls the API endpoint /libraries/v2, LibrePCB 3.x will call /libraries/v3 and so on. This is important to keep older LibrePCB versions working fine even after a new major release with an updated file format comes out.
  • Make sure that the libraries format_version is always lower or equal to the API version number. For example the JSON of /libraries/v2 must never contain libraries with format_version=3. LibrePCB 2.x cannot open libraries with format_version 3, so the library would basically disappear after installation. I’d recommend to add an assert to the shell script to guarantee this invariant is always fulfilled. (note that since LibrePCB v1, the format_version can be considered as an integer, it won’t ever be a “major.minor” version number again.)

That was probably the spam protection of the forum. I have assigned you a higher trust level, I guess ZIP should now work.

ok, great.

here is the corrected Script, now attached

create_librePCB_json.sh.zip (1.8 KB)

1 Like