The five-day visit to Taiwan last week by Prime Minister Peter W. Botha, reciprocating a visit here in March by Prime Minister Sun Yun Suan of Taiwan, underscored the growing economic, military and political relations between the two isolated countries in their search for dependable allies against communism.

Little is publicly said in either country to draw attention to the fact that they see the communist threat in terms of two separate countries. For South Africa, the greatest danger to world security, especially its own, is Soviet expansionism. Taiwan, however, is more preoccupied with its huge neighbor, the People's Republic of China.

And nothing is openly said here about the South African government's tacit approval of what appear to be regular visits to Peking by groups of South Africa businessmen and bankers, according to several reliable sources. At least one of those visits included a junior-level South African government official, according to one South African source.

Despite these visits, or perhaps because of them, the South African delegation was feted with much fanfare in Taiwan last week. At a banquet for Botha, who was on his first state visit abroad and the first of a South African leader to the Far East, he was praised by Premier Sun for being aware of the dangers in playing what the Taiwanese premier called "the China card." Sun noted the two countries' common determination to withstand the "communist onslaught."

Botha, who repeatedly compared Taiwan's "national will" to survive to his own administration's, observed that "our two countries have experience of the reality of the communist threat and of the transformation under pressure of fair-weather friends into vocal critics. We have seen many former allies choose to leave us to sink or swim on our own." The unnamed "ally" of Botha's remarks was Washington.

Botha visited a military training academy and was reportedly impressed with its program of anticommunist psychological indoctrination.

Behind the rhetoric of their relationship is a burgeoning trade that offers South Africa an outlet for its expanding manufacturing sector and if necessary, a disguised conduit for its products, and purchases, against boycotts. Now 12th on the list of countries trading with South Africa, Taiwan could move into the top 10 this year, according to the South African Federation of Trade Organizations. The two-way trade includes South African coal, steel and food products and Taiwanese textile and mechanical equipment. It is expected to reach more than $520 million in 1980, according to South Arican-run radio.

This month South African Airways inaugurated a direct flight once a week to Taipei.

Asked about increased military cooperation, Botha told a press conference, "If the communist world can cooperate to protect their interests, I do not see why democratic countries cannot operate to protect their interests."

Botha also did not prelude future nuclear cooperation with Taiwan. "Should any discussions or agreements take place between us, they will be to enhance the use of [nuclear] power for peaceful purposes," he told reporters. e"We are modern states and we should share in modern development."

During Sun's visit here the two countries signed a contract under which the island nation will buy $520 million in South African uranium that will be used to fuel Taiwan's nuclear power plants, the Taiwan premier said.

The six-year contract, to run from 1984 to 1990, is one of the largest uranium deals ever concluded by South Africa, according to a spokesman for the S.A. Nuclear Fuel Corp.

Taiwan has one nuclear power station in operation, for which the United States supplies the fuel. It plans three more by the end of this decade, a Taiwan Embassy spokesman said. The raw uranium purchased from South Africa must still be enriched and processed before it can be used in those plants.

South Africa has two nuclear power plants scheduled to come on stream in 1982 and 1983 but the United States has refused to give it the processed fuel its needs to run them because Pretoria has balked at international inspection of its enrichment facilities.

The South African visit received extensive press coverage in Taiwan, but little exposure was given to this country's domestic racial policies under which the 10,000 Chinese living here are regarded unofficially as "honorary whites."

This means Chinese are given access to "white" restaurants and theaters and can live in "white" neighborhoods if they have permission of their neighbors. But they are banned from marrying a person of another race and this week a front-page newspaper story told how two Chinese girls were refused permission to use their neighborhood public swimming pool.

On his return from Taiwan, Botha promised that the government would look into improving the position of Chinese living here.