safe to use API-version 1 for Htaccess

0884094

Member
Nov 14, 2013
17
7
53
cPanel Access Level
Root Administrator
Hi friends, I want to programmatically set up .htpasswd authentication on many cPanel websites. I need functions to turn off/on, create/delete/list users.

cPanel API 1 has a set of functions that do everything:
cPanel API 1 Functions - Htaccess::set_pass - Developer Documentation - cPanel Documentation

However they come with a prominent warning: cPanel API 1 is deprecated. We strongly recommend that you do not use cPanel API 1. However, no equivalent function exists in our newer APIs.

There is an API 2 module that only does "listusers", without ability to edit, and it has a similar warning: We strongly recommend that you use UAPI instead of cPanel API 2. However, no equivalent UAPI function exists.
cPanel API 2 Functions - Htaccess::listuser - Developer Documentation - cPanel Documentation

Would it be reasonable for me to just code up what I need in API v1? I note that the cPanel interactive dashboard has functions to manage .htpasswd access... I assume these are using API v1 under the hood? Is there some better approach that I don't know about?

Thanks!
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Hi @0884094

As indicated in the warning:
Code:
We strongly recommend that you do not use cPanel API 1. However, no equivalent function exists in our newer APIs.
There is no equivalent in either cpapi2 or UAPI so you'd have to use cpapi1

I do believe we're looking at phasing out cpapi1 and part of that is evaluating the functions that are present (but not in UAPI) and developing equivalencies for them.

Thanks!